Problem:


Score : 300 points

Problem Statement

Given are N integers A_1,\ldots,A_N.

Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Constraints

2 \leq N \leq 2\times 10^5

0 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

Print \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j, modulo (10^9+7).

Sample Input 1

3
1 2 3

Sample Output 1

11

We have 1 \times 2 + 1 \times 3 + 2 \times 3 = 11.

Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829



Sample input:
3
1 2 3


Sample output:
11

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
import numpy as np
Sum_a = 0
Sum_j_list = np.cumsum(alist)
for i in range(N-1):
  Sum_j = Sum_j_list[N-1] - Sum_j_list[i]
  Sum_a += int((alist[i] * Sum_j) % (1e9+7))
print(int(Sum_a % (1e9+7)))

Submission status: Wrong Answer

Solution code:
_N = int(input())
_list = list(map(int, input().split()))
_list.sort()

_sum = 0
_answer = 0

print(_list)
for i in range(_N):
  for l in range (_N):
    if i < l:
      _sum += _list[i] * _list[l]

_answer = _sum % (10**9+7)
print(int(_answer))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr=list(map(int, input().split()))



array_sum = 0
for i in range(0, n, 1): 
    array_sum = array_sum + arr[i] 
  
array_sum_square = array_sum * array_sum 
  
individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum += arr[i] * arr[i] 
  
b=(array_sum_square-individual_square_sum)%1000000007
b=int(b)
b=b/2;
b=int(b)
print(b)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
ct = 0
n = N - 1
for i in range(n):
    for j in range(i+1, N):
        print(A[i])
        print(A[j])
        x = A[i] * A[j]
        ct += x
print((ct % mod))

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
a_list = list(map(int, input().split()))
result = []

a_list2 = map(lambda x: x % 1000000007, a_list)

for a in itertools.combinations(a_list2, 2):
    b, c = a
    result.append(b * c)

print(sum(result))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.asarray(input().split()).astype(np.int)
A_sq = np.square(A)

print(int(np.mod(((A.sum())*(A.sum())-A_sq.sum())/2, 10**9+7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int,input().split()))
sum = 0

for i in range(N):
  for j in range(N):
    if i == j or i > j :
      continue
    else:
      sum += nums[i]*nums[j]
      
print(sum%10**9+7)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split(" ")))
res = 0
for i in range(N):
    for j in range(i+1, N):
        print(A[i], A[j])
        res += A[i]*A[j]

print(res)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
import math
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(add(result[-1], x))
    return result

#N = int(input())
#C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))

inv = cumsum(list(reversed(A)))
c = 0
for i in range(0,N-1):
    print(N-i-2)
    c = add(c,mul(A[i],inv[N-i-2]))

print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
assert(len(A) == N)
res = 0
for i in range(N-1):
    sum_now = A[i]*sum(A[i+1:])%(1e9+7)
    res = (res + sum_now)%(1e9+7)
print(int(res))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = 0
ans = 0
for i in range(len(a)):
  s += a[i]
for i in range(len(a)-1):
  s -= a[i]
  ans += s*a[i]
  ans %= 1e9+7
print(int(ans))

Submission status: Wrong Answer

Solution code:
mod = 1e9 +7
n = int(input())
a = list(map(int,input().split()))
a_sum = sum(a)
a_sum_sq = (a_sum*a_sum)%mod
i = 0
for y in range(n):
    i += (a[y]*a[y])
    i %= mod
print(int((((a_sum_sq-i)+mod)%mod)/2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = tuple(map(int,input().split()))
b = sum([(i**2) for i in a])
ans = int((sum(a)**2-b)/2)%(10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    suma = 0
    for ai in a:
        suma += ai
        suma %= mod
    ans = 0
    for ai in a:
        tmp = suma
        tmp -= ai
        tmp %= mod
        ans += tmp * ai
        ans %= mod
    print(ans//2)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
l = set(map(int, input().split()))
total = 0
mod = 1000000007
L = itertools.combinations(l, 2)
for a,b in L:
    total += ((a % mod) * (b % mod)) % mod
print(total % mod)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))

ans = sum(A) ** 2


for a in A:
  ans = ans - a ** 2

ans = ans // 2

print(int(ans%(10^9+7)))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
s=0
for i in range(N):
  s+=A[i]*A[i]
m=sum(A)
k=(m*m-s)/2
print(int(k%(10**9+7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
s = 0
for i in a:s+=i

ans = 0
for i in a:
    ans += ((i*s)-(i*i))/2
    ans = ans % MOD

print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
import numpy as np
Sum_a = 0
Sum_j_list = np.cumsum(alist)
for i in range(N):
  Sum_j = Sum_j_list[N-1] - Sum_j_list[i]
  Sum_a += (alist[i] * Sum_j) % (1e9+7)
print(int(Sum_a % (1e9+7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
bob = [int(x) for x in input().split()]
sum = sum(bob)
sum = sum * sum
cum = 0
for i in bob:
    cum += i * i
print(int((sum - cum) / 2 % (1e9 + 7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))


A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) / 2
print(int(Answer%(10**9 + 7)))

Submission status: Wrong Answer

Solution code:
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np

nmod = 1e9 + 7

(N,) = list(map(int, input().split()))
A = list(map(int, input().split()))

ans = 0
tsum = 0
for i in range(N - 1, 0, -1):
    tsum += A[i]
    tsum %= nmod
    tmp = (A[i - 1] * tsum) % nmod
    ans += tmp
    ans %= nmod

print(int(ans))

Submission status: Wrong Answer

Solution code:
def fastSumPair(A):
    L = len(A)
    M = 1000000007
    
    # (a + b + c)**2 = a**2 + b**2 + c**2 + 2*(a*b + b*c + c*a)
    # derive from this equation
    
    # first array
    A_1_sum = 0
    for i in range(0, L):
        A_1_sum = (A_1_sum + A[i]) 
    
    A_1_sum = (A_1_sum ** 2) 
        
    # second array
    A_2_sum = 0
    for i in range(0, L):
        A_2_sum = (A_2_sum + A[i] ** 2) 
                  
    return int((A_1_sum - A_2_sum) / 2) % M

N = int(input())
A = list(map(int, input().rstrip().split()))
print(fastSumPair(A))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

z = 0
for i in range(n):
    z += a[i]

y = (z % 1000000007)** 2

x = 0
for j in range(n):
    x += a[j] ** 2

p = ((y - x) / 2) % 1000000007
print(int(p))

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


K = 10**9+7
N = II()
a = np.array(acinput())
a = a[a != 0]
N = len(a)
s1 = 0
for i in range(N):
    s1 += a[i]
    # s1 %= K

# s1%=K
# s2 = s1
s = (s1*s1)
T = 0
for i in range(N):
    T += a[i]*a[i]
    # T %= K
# s += K
tmp = int((s-T)/2) % K
print(tmp)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])
mod = 10**9+7
mod_sum = 0
a_sum = sum(a)
for i in range(n-1):
    a_sum -= a[i]
    mod_sum += a[i] * a_sum % mod

print(mod_sum%mod)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))

if 0 in a:
  print(0)
b=a.count(1)
if 1 in a:
  a.remove(1)
ans=sum(a)*b
for i in range(len(a)-1):
  p=a.pop()
  q=sum(a)
  ans+=p*q
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
total = (sum(a))**2
ans = 0
m = 10**9+7
cur = sum([a[i]**2 for i in range(n)])
ans = (total-cur)/2
ans = ans%m
print(round(ans))

Submission status: Wrong Answer

Solution code:
size = int(input())
arr = [int(i) for i in input().split()]

sum=0;
sum2 =0;
for i in range(size):
  sum=sum+int(arr[i])
  #print(sum)
  sum2 = sum2 + int(arr[i])**2
  #print(sum2)
  

sum  = (sum**2 - sum2)/2

print(sum%1000000007)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
S=0
while 1:
  for i in range(0,len(A)-1):
      S=S+A[0]*A[i+1]
  if len(A)==1:
    break
  else:
    A.remove(A[0])
print(S)

Submission status: Wrong Answer

Solution code:
N = int(input())
input1 = input()
input1 = input1.split()
A = []
sum = 0
for i in input1:
    A.append(int(i))
for i in range(N):
    sum += A[i]
sum_square = sum * sum 
individual_square_sum = 0
for i in range(N): 
    individual_square_sum += A[i]*A[i] 
print(int((sum_square - individual_square_sum)/2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

m = 1000000007

s = sum(a)
ans = 0
for i in range(n):
    aa = a[i]
    ans += aa * (s - aa)

ans = int(ans/2)
ans = ans % m

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0

for i in range(n - 1):
    for j in range(n - (i + 1)):
        print(a[i] , '*' , a[i + (j + 1)])
        res =  (res + a[i] * a[i + (j + 1)] % mod) % mod

print(res)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
C=[A[i]**2 for i in range(N)]
print(int(((sum(A)**2-sum(C))/2)%(10**9+7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
f = sum(a)%mod
ans = 0
for i in range(n):
  e = (f-a[i])%mod
  ans+= (e*a[i])%mod
  ans%=mod
print(ans//2)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
a = a%(10**9+7)
tmp=0
ans=0
for i in range(n-1):
    tmp=tmp+a[(i+1)*-1]
    ans=ans+(a[(i+2)*-1]*tmp)%(10**9+7)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))


A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) / 2
if Answer <= 10**9:
    print(int(Answer))
else:
    print(int(Answer % (10**9+7)))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
#n = (10**5)*2
#a = np.array([int(10**9)]*n)
mod = 10**9+7
ans = 0
c = [0]*n
c[n-1] = a[n-1]
for i in range(n-1,1,-1) :
    c[i-1] = c[i]+a[i-1]

c.pop(0)
for i in range(0,n-1) :
#    print(i,c[i])
    ans += a[i]*c[i]%mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
N = int(input().rstrip()) #個数
line = input().rstrip().split(" ") #Ai
isum = 0
sum = 0

for i in range(N - 1):
    a = int(line[i])
    for j in range((i + 1), N):
        isum += int(line[j])
    sum = isum * a

print(isum % (1000000007))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

sum = 0
for i in range(N - 1):
    jsum = 0
    for j in range(i + 1, N):
        jsum += A[j]
    sum += A[i]*jsum

print(int(sum % (1e9 + 7)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
s = 0
Sum = 0
for i in range(n):
    s = (s+a[i]) % mod
for i in range(n):
    Sum = (Sum+a[i]*(s-a[i])) % mod
ans = (Sum / 2) % mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
sum1=0
sum2=0
for i in range(N):
    sum1+=A[i]
    sum1%=mod
for i in range(N):
    sum2+=(A[i]%mod)**2
    sum2%=mod
ans=(((sum1**2)-sum2)%mod)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)-1):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = list(set(lst))

for i in range(len(lst)-1):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7

def findProductSum(A, n):
    array_sum = 0
    for i in range(n):
        array_sum += A[i]
    array_sum_square = array_sum * array_sum % MOD
    individual_square_sum = 0
    for i in range(n):
        individual_square_sum = (individual_square_sum + A[i] * A[i]) % MOD
    if array_sum_square < individual_square_sum:
        array_sum_square += MOD
    return (array_sum_square - individual_square_sum) / 2

N = int(input())
a = [int(_) for _ in input().split()]
print(int(findProductSum(a, N)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    for j in range(i+1,n):
        s = a[i] * a[j]
        ans = ans + s

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
m = 1e9 + 7

def mod(a, m):
    return (a%m + m) % m

def solve(arr, n):
    arr_sum = 0
    for i in range(n):
        arr_sum += arr[i]
        arr_sum = mod(arr_sum, m)
    
    arr_sum_sq = arr_sum 
    arr_sum_sq = mod(arr_sum_sq * arr_sum, m)
    
    ind_sum = 0

    for i in range(n):
        ind_sum += arr[i]*arr[i]
        ind_sum = mod(ind_sum, m)
    
    return mod(arr_sum_sq - ind_sum, m)


print(int(solve(arr, len(arr))/2))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
# = str(input())
# = map(int, input().split())
A = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

total = (sum(A)%(10**9+7))**2
doubleA = (np.asarray(A)%(10**9+7))**2

minustotal = sum(doubleA)

print(((total-minustotal)%(10**9+7))//2)

Submission status: Wrong Answer

Solution code:
def solve(n,A):
	mod=10**9+7
	s=0
	print(A)
	for i,x in enumerate(A):
		for j in range(i+1,n):
			s+=(x*A[j])
	return s%mod


N=int(input())
A=list(map(int,input().split()))
print(solve(N,A))

Submission status: Wrong Answer

Solution code:
a = [input().split() for l in range(2)]
count = 0
N = int(a[0][0])

for j in range(N):
    b = a[1][j+1:]
    b = [int(x) for x in b]
    count = (int(a[1][j])*sum(b)+count) % 1000000007
    print(a[1][j])
    print(count)
    print(b)
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
A= list(map(int,input().split()))
mod_num = 1.0e+9 + 7
rest = 0
for i in range(len(A)):
  A[i]= A[i]%mod_num
for i in range(N-1):
  rest += (A[i]*(sum(A[i+1:])%mod_num))%mod_num

    
print(int(rest%mod_num))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))


A_sum = 0
for i in range(0, N, 1):
    A_sum = A_sum + A[i]

A_sum_sq = A_sum * A_sum

idv_sq_sum = 0
for i in range(0, N, 1):
    idv_sq_sum += A[i] * A[i]

Answer = (A_sum_sq -
          idv_sq_sum) / 2
if Answer > 10**9:
    print(int(Answer % (10**9+7)))
else:
    print(int(Answer))

Submission status: Wrong Answer

Solution code:
n=int(input())
ai = list(map(int,input().split()))
kei = 0
S = []
for i in range(0,n-1):
    for k in range(1,n-i):
      kei = ai[i]*ai[i+k]
      S.append(kei)
print(sum(S))

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
A = list(map(int,input().split()))

sum=0
mod = 1000000007
for v in itertools.combinations(A, 2):
    v0 = v[0]%mod
    v1 = v[1]%mod
    sum += v0*v1%mod
print(sum)

Submission status: Wrong Answer

Solution code:
n=int(input())
list=input().split()
sum=0
for i in range(n):
 sum+=int(list[i])
sum=sum*sum
sum2=0
for i in range(n):
 sum2+=int(list[i])*int(list[i])
sum-=sum2
sum/=2
sum%=1000000007
print(int(sum))

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
t=np.array(input().split(' '))
num=np.zeros(n)
for a in range(n):
  num[a]=int(t[a])
a=np.sum(num)**2
b=np.sum(num**2)
x=int((a-b)/2)
x=x%(10**9+7)
print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
i2 = input().split(" ")
A = [] 
for i in i2:
    A.append(int(i))
def findProductSum(A, n): 
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  

    array_sum_square = array_sum * array_sum 
  
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    return int((array_sum_square - individual_square_sum) / 2)
      
  
print(findProductSum(A,n) % ((10**9)+7)  )

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
MOD=7+10**9
ans=0
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        print(A[i],A[j])
        ai= A[i] % MOD
        aj=A[j] % MOD
        ans = ans +ai*aj % MOD
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)
square = 0
for i in range(N):
    square += A[i] * A[i]
res = ((sumA * sumA - square)/2)%(1000000007)
print(int(res))

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
ss=0
s=0
for i in range(0,n,1):
    ss=ss+arr[i]**2
    s=s+arr[i]
ans=(s**2-ss)/2
print(int(ans%(10**9+7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))


B = 0
C = 0
for i in range(N):
    B += A[i]
    C += A[i]**2

ans = (((B**2) - C) / 2) % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
t = 10**9+7
ans = 0
for i in range(n-1):
  for j in range(i-1,n):
    ans = (ans+a[i]*a[j])%t
print(math.floor(ans%t))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int, input().split()))
s1 = sum(a)
a2 = np.array(a,dtype=int)
a3 = a2**2
s2 = sum(a3)
print(((s1**2-s2)//2)%(10**9+7))

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))

ans = sum(A)^2

for a in A:
  ans -= a^2

ans /= 2

print(int(ans%(10^9+7)))

Submission status: Wrong Answer

Solution code:
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)

result = (s1**2-s2)/2
print(round(result%m))

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict

input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

D = defaultdict(int)
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        v = A[i] * A[j] % MOD
        D[v] += 1
print(D)

Submission status: Wrong Answer

Solution code:
import math
from itertools import combinations
m = 10 ** 9 +7

n = int(input())
a = list(map(int, input().split()))

b = list(combinations(a, 2))
ans = 0

for i in range(len(b)):
    ans += (b[i][0] * b[i][1]) % m
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
sum1=0
sum2=0
for i in range(len(A)):
    sum1+=A[i]
    sum1%=mod
for i in range(len(A)):
    sum2+=(A[i]%mod)**2
    sum2%=mod
ans=(((sum1**2)-sum2)%mod)/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
# Efficient python 3 program to find sum 
# pair products in an array. 

# required function 
mod = 1e9+7
def findProductSum(A, n): 
	
	# calculating array sum (a1 + a2 ... + an) 
	array_sum = 0
	for i in range(0, n, 1): 
		array_sum = (array_sum + A[i])

	# calcualting square of array sum 
	# (a1 + a2 + ... + an)^2 
	array_sum_square = (array_sum * array_sum )

	# calcualting a1^2 + a2^2 + ... + an^2 
	individual_square_sum = 0
	for i in range(0, n, 1): 
		individual_square_sum += A[i] * A[i] 

	# required sum is (array_sum_square - 
	# individual_square_sum) / 2 
	return (array_sum_square -individual_square_sum) / 2

# Driver code 

if __name__ == '__main__': 
	n = int(input()) 
	l = list(map(int, input().split())) 
	print(int(findProductSum(l, n)%mod)) 
	
# This code is contributed by 
# Ritik Agarwal

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N = int(input())
As = list(map(int,input().split()))
As = np.array(As)
seihokei = sum(As)**2
shoseihokei = (As**2).sum()
answer = math.floor((seihokei-shoseihokei)/2+0.1)
answer = answer % (10**9+7)
print( math.floor(answer+0.1) )

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 1
res = 0

def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m

for i in range(N):
    ans *= A[i]
    ans %= 10 ** 9 + 7

for i in range(N):
    res += ans * modinv(A[i], 10 ** 9 + 7)
    res %= 10 ** 9 + 7

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

z = 0
for i in range(n):
    z += a[i]

y = ((z % 1000000007)** 2) % 1000000007

x = 0
for j in range(n):
    x += a[j] ** 2


p = int(((y - x) / 2) % 1000000007)
print(p)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
m = 1e9 + 7

def mod(a, m):
    return (a%m + m) % m

def solve(arr, n):
    arr_sum = 0
    for i in range(n):
        arr_sum += arr[i]
        arr_sum = int(mod(arr_sum, m))
    
    arr_sum_sq = arr_sum 
    arr_sum_sq = int(mod(arr_sum_sq * arr_sum, m))
    
    ind_sum = 0

    for i in range(n):
        ind_sum += arr[i]*arr[i]
        ind_sum = int(mod(ind_sum, m))
    
    return int(mod(arr_sum_sq - ind_sum, m))


print(int(solve(arr, len(arr))/2))

Submission status: Wrong Answer

Solution code:
MOD = 1000000007
number_list = list(map(int, input().split()))
sum_number = 0

for i, number in enumerate(number_list):
	sum_number += (number*sum(number_list[i+1:])) % MOD
	sum_number %= MOD
print(sum_number)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7

N = int(input())
A = list(map(int, input().split()))

A = [a % MOD for a in A]
A_d = [(a * a) % MOD for a in A]
res = ((sum(A)**2) % MOD - sum(A_d) % MOD) % MOD
res //= 2

print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
a =list(map(int,input().split()))
x=0
y=0
for i in range(N):
    y=y+a[i]**2
            

x=int((sum(a)**2-y)/2)


z=10**9+7
if (x>z):
    print(x%z)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = input()
a = l.split(' ')

tmp = 0
tmp2 = 0

for i in range(n):
    tmp += int(a[i])

for i in range(n):
    tmp2 += int(a[i])*int(a[i])

total = int((tmp*tmp-tmp2)/2)

print(int(total%1000000007))

Submission status: Wrong Answer

Solution code:
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)

result = (s1**2-s2)/2
print(int(result%m))

Submission status: Wrong Answer

Solution code:
n = 2 # nは入力回数
num_list = []
for i in range(n):
    num_list.append(list(map(int,input().split())))
print(num_list)

N = num_list[0]
A = num_list[1]

A2 = A

Sum = 0

for i in A:
    for j in A2:
        Sum +=  i*j

for i in A:
    Sum -= i**2

Sum = int(Sum/2)

mod_n = 10.0E9 +7

print(int(Sum % mod_n))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))

A_array = np.array(A)[::-1]
A_cum = A_array.cumsum()[::-1]

ans = 0
for i in range(N-1):
    ans += A_cum[i+1] * A[i]

print(ans%(10**9 +7))

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
a = list(map(int, input().split()))
amaria = []
ans = 0
p = 10 ** 9+7
#for i in itertools.combinations(a,2):
    #ans += i[0]* i[1]
    #print(ans)
for i in range(n):
    amaria.append(a[i]%p)
for j in itertools.combinations(amaria,2):
    ans += j[0]* j[1]
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
MOD = 1000000007

sum1 = 0
for i in range (0,n):
        sum1 += a[i]
        
sum1 *= sum1

sum2 = 0
for i in range (0,n):
        sum2 += a[i] * a[i]


print((int)((sum1 - sum2)/2)%MOD)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]

mod = 10**9 + 7
x = sum(A)
y = x**2 % mod - sum([x**2 for x in A]) % mod
print(int(y / 2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

ans = 0
for i in range(N - 1):
    ans += (A[i] * A[i + 1])
    ans %= mod

ans += (A[0] * A[-1])

print(ans % mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int ,input().split()))
MOD = 10**9+7

sum = 0
for i in range (N):
    sum += A[i] % MOD

ans = 0
for i in range(N):
    sum -= A[i]
    ans += (A[i] * sum) % MOD

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[int(s) for s in input().split()]
d_1=(sum(d))**2
d_2_pre=list(map(lambda x:x**2,d))
d_2=sum(d_2_pre)
print(int((d_1-d_2)/2)%((10**9)+7))

Submission status: Wrong Answer

Solution code:
mod = 1000000007
def findProductSum(A, n): 
    array_sum = 0
    for i in A: 
        array_sum = (array_sum + i)%mod
    array_sum_square = pow(array_sum,2,mod)
    individual_square_sum = 0
    for i in A: 
        individual_square_sum = (individual_square_sum + (i * i)%mod)%mod
    tmp = (((array_sum_square - individual_square_sum)%mod) // 2)%mod
    return tmp
n = int(input())
lis = list(map(int,input().split()))
print(findProductSum(lis,n))

Submission status: Wrong Answer

Solution code:
N = int(input())
A=list(map(int, input().split()))
B=[A[N-1]]
#print(B[0])
for i in range(len(A)-2):
    #print(i)
    b=B[i]+A[N-2-i]
    B.append(b)
print(B)
total=0
for i in range(len(B)):
    total += A[i]*B[len(B)-1-i]

print(total%(10**9+7))
    #print(v)

Submission status: Wrong Answer

Solution code:
import numpy
 
N = int(input())
A = list(map(int, input().split()))

ans = 0
res = numpy.cumsum(A)
sum_A = sum(A)

for i in range(N-1):
  ans += A[i]*(sum_A-res[i])
  
mod = 10**9 + 7
print(ans%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
t=np.array(input().split(' '))
num=np.zeros(n)
for a in range(n):
  num[a]=int(t[a])
a=np.sum(num)**2
b=np.sum(num**2)
x=int((a-b)/2)
x=(x-1)%(10**9+7)
print(x)

Submission status: Wrong Answer

Solution code:
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)

result = (s1**2-s2)/2
print(result%m)

Submission status: Wrong Answer

Solution code:
MOD  = 1000000007

n=int(input())
a=list(map(int,input().split()))

array_sum = 0
for i in range(0, n, 1): 
    array_sum = (array_sum + a[i] )

array_sum_square = (array_sum * array_sum )

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum = (individual_square_sum+(a[i] * a[i]))

ans=(array_sum_square - individual_square_sum) / 2
print(int(ans%MOD))

Submission status: Wrong Answer

Solution code:
mod=(10**9)+7
n=int(input())
a=list(map(int,input().strip().split(' ')))
s=0
for x in a:
	s= (s+x)%mod
s=(s*s)%mod
t=0
for x in a:
	t= (t+ (x*x)%mod)%mod
ans=((((s-t)%mod+mod)%mod)//2)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline

N = int(input())
A = list(map(int,input().split()))
M = 0
for i in range(0,N-1):
  for j in range(i+1,N):
    M = M + A[i]*A[j]
if M >= 1000000007:
  M = M - 1000000007
  if M >= 1000000007:
    M = M - 1000000007
    if M >= 1000000007:
      M = M - 1000000007
      if M >= 1000000007:
        M = M - 1000000007
        if M >= 1000000007:
          M = M - 1000000007
          if M >= 1000000007:
            M = M - 1000000007
            if M >= 1000000007:
              M = M - 1000000007
  
print(M)

Submission status: Wrong Answer

Solution code:
p = int(1e9+7)
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)):
    A[i] %= p
for i in range(len(A)-1):
    for j in range(i+1, len(A)):
        ans += A[i]*A[j] 
        ans %= p

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

N = int(input())
h = list(map(int, input().split()))
h.sort(reverse=True)
h2 = copy.copy(h)
ans = 0
s = np.sum(h2)
for i in range(N-1):
    s -= h[i]
    ans += h[i] * s
ans = ans % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(N):
  s += a[i]

s = s*s

for i in range(N):
  s -= a[i]*a[i]

s = int(s/2)

while s >= 10**9 +7:
  s = s % (10**9 +7)

print(int(s))