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())
a=list(map(int,input().split()))
MOD=1000000007
wa=0;
nijowa=0;
for i in a:
    #print(i)
    wa=wa+i;
    wa%=MOD
    nijowa+=(i*i)%MOD
    nijowa%=MOD
ans=(wa*wa)%MOD-nijowa
if ans<0:
    ans=ans+MOD
print(int(ans/2))

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
value = list(map(int, input().split()))
a = np.array(value)
mod = 10**9 + 7
result = 0
for i in range(n - 1):
  result += a[i] * np.sum(a[i+1::])
  result = result % mod
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int,input().split())
ans = 0
ans2 = 0
mod = 10 ** 9 + 7
for a in A:
    ans += a
    ans2 += a**2
    ans %= mod 
    ans2 %= mod
print(((ans ** 2 + mod -ans2)//2)%mod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
#d, t, s = map(int, input().split())
s = sum(a) % (10**9 + 7)
#s = 0
#for i in range(n):
#  s += a[i]
#  s = s % (10**9 + 7)
b = [0] * n
for i in range(n):
  b[i] = a[i] * s - a[i] * a[i]
#  b[i] = (a[i]*s) % (10**9 + 7)- (a[i]*a[i]) % (10**9 + 7)

print(int(sum(b)/2) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float, input().split()))
S = sum(A)
result = 0
mod = 10 ** 9 + 7
for a in A:
  S -= a
  result += a * S
  result %= mod
print("{:.0f}".format(result))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
t = 0 
for i in range(len(A) - 1): 
        print(A[i] , sum(A[i + 1:]))
        t = (t + (A[i] * sum(A[i + 1:]))) % 1000000007
print(t)

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**2)%mod
t=0
for x in a:
	t= (t+ x**2)
ans=((((s-t)%mod+mod)%mod)//2)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy
ans = 0
mod = 10**9 +7

a_r = list(reversed(a))
res = numpy.cumsum(a_r[:-1])
res_l = list(reversed(res))

for i in range(len(a)-1):
    ans += (a[i]*res_l[i]%mod)
    
print(ans % (mod))

Submission status: Wrong Answer

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

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 % MOD + a[i]%MOD)%MOD 

array_sum_square = pow(array_sum,2,MOD)

individual_square_sum = 0
for i in range(0, n, 1): 
    individual_square_sum+= pow(a[i],2,MOD)
    individual_square_sum%MOD

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

Submission status: Wrong Answer

Solution code:
u=0
u=int(input())
A = list(map(int,input().split()))
n = len(A)
prr = 0
for i in range(n):
    for j in range(i + 1, n):
        prr = prr + A[i] * A[j]
print(prr)

Submission status: Wrong Answer

Solution code:
# cook your dish here
n=int(input())
a = list(map(int,input().split()))
sum = 0
sq = 0
mod = 1000000007
for i in range(len(a)):
    sum += a[i]
    sq += a[i]*a[i]
ans = ((sum*sum - sq)/2)%mod
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

p = 0
for i in range(n):
  p += a[i] ** 2

print(int(((sum(a) * sum(a) - p)/ 2 ) % (10**9+7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
S = 0
B = 0

for i in range(N):
  A[i] = int(A[i])
  B += (A[i]*A[i])

print(int(( (sum(A)*sum(A)) - B ) % ( 10**9 + 7 ) / 2 ) )

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int, input().split()))
ans=sum(l)**2
sq=0
for i in range(n):
  sq+=l[i]**2
ans=(ans-sq)/2

import numpy as np
print(int(np.mod(ans, 10**9+7)))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=list(map(int,input().strip().split()))
su=0
m=0
for i in range (n):
	su=su+a[i]
	m=m+a[i]*a[i]
ans=su*su-m
mod=1000*1000*1000+7
op=ans/2
op=op%mod
op=math.floor(op)
print(op)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

An = list(map(int, input().split()))
total = sum(An)
ans = 0
for A in An:
    At = A * (total-A)
#     print(A, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
MOD = 1e9 + 7
N = int(input())
A = list(map(int, input().split()))
c = 0
S = sum(A)
for i in range(N):
    c += (A[i] % MOD) * ((S - A[i]) % MOD)
    c %= MOD
mod = pow(2, -1, 1000000007)
c = c * mod
c %= MOD
print(int(c))

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

N = int(input())
h = list(map(int, input().split()))
h2 = copy.copy(h)
ans = 0
s = np.sum(h2) % (10**9 + 7)
for i in range(N):
    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
# dp = [1 for _ in range(n)]
for i in range(n):
	tmp = 0
	for j in range(i+1, n):
		tmp += a[j]
	s += (a[i]% (10**9+7))*(tmp% (10**9+7))
		
print(s)

Submission status: Wrong Answer

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

import itertools

for pair in itertools.combinations(a,2):
    print(pair)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a_s = list(map(int, input().split()))
a_s_np = np.array(a_s)

inpro = np.inner(a_s, a_s)
sum_a = np.sum(a_s)

ans = int(((sum_a * sum_a - inpro) // 2) % (1e9 + 7))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    mylist = LI()
    shift = int(10e9 + 7)
    S = sum(mylist)
    res = 0
    
    for i in mylist:
        S-=i
        if S==0:
            break
        res += (i % shift) * (S % shift)
        res = res % shift
    

    print(int(res))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

size = len(ls)

ans = 0
for i in range(size - 1):
  gou = sum(ls[i+1:size])
  ans = ans + (gou * i % 100000007)

print(ans)

Submission status: Wrong Answer

Solution code:
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            print(A[i], A[j])
            ans += (A[i] * A[j] % mod)
    print(ans % mod)

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=list(map(int,input().strip().split()))
sum=0
m=0
for i in range (n):
	sum=sum+a[i]
	m=m+a[i]*a[i]
ans=sum*sum-m
mod=1000*1000*1000+7
op=ans/2
op=op%mod
op=math.floor(op)
print(op)

Submission status: Wrong Answer

Solution code:
a=int(input())

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

sum=0

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]

print(sum%(pow(9, 10)+7))

Submission status: Wrong Answer

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

M = int(1e9+7)

s = 0
for a in A:
    s += a

ans = 0
for a in A:
    ans += a * (s-a)

ans /= 2
print(int(ans % M))

Submission status: Wrong Answer

Solution code:
input()
lis = list(map(int,input().split()))
def sol(lis):
    s = [0]*len(lis)
    x = 0
    for i in range(len(s)-1,-1,-1):
        s[i] +=x
        x +=lis[i]
    res = 0
    for i in range(len(lis)):
        res += lis[i]*s[i]
    print(res)
sol(lis)

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**2)%mod
t=0
for x in a:
	t= (t+ x**2)
ans=((s-t)//2)%mod
print(ans%mod)

Submission status: Wrong Answer

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

AA = 0
ans = 0
for a in A:
    AA = (AA + pow(a, 2, MOD))%MOD
    ans = (ans + a%MOD)%MOD
ans = (((pow(ans, 2, MOD) - AA%MOD)%MOD)//2)%MOD
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
#import sys 
import numpy as np

def readline():
	return map(int,input().split())
def solve():
	n=int(input())
	l=list(readline())
	x = np.array(l)
	result = ((x.sum()**2 - x.dot(x)) // 2)%1e9+7
	print(int(result))
if __name__ == "__main__":
	#code goes below
	solve()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a_s = list(map(int, input().split()))
a_s_np = np.array(a_s)

inpro = np.inner(a_s, a_s)
sum_a = np.sum(a_s)

ans = (sum_a * sum_a - inpro) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float, input().split()))
S = sum(A)
result = 0
mod = 10 ** 9 + 7
for a in A:
  S -= a
  result += a * S
  result %= mod
print(int(result))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

first = a[0]

ans = first*a[1]

print(ans)
for i in range(1, n-1):
    first += a[i]
    ans += first*a[i+1]

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

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=list(map(int,input().strip().split()))[:n]
sum=0
m=0
for i in range (n):
	sum=sum+a[i]
	m=m+a[i]*a[i]
ans=sum*sum-m
mod=1000*1000*1000+7
op=ans/2
op=op%mod
op=math.floor(op)
print(op)

Submission status: Wrong Answer

Solution code:
mod = ((10**9)+7)
def findProductSum(A, n): 
    array_sum = 0
    for i in A: 
        array_sum = (array_sum + i)%mod
    array_sum_square = (array_sum * array_sum)%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:
from itertools import product
n=int(input())
l=list(map(int,input().split()))
m=list(product(l,l))
N=(10**9)+7
ans=0
for i in range(len(m)):
    if m[i][0]!=m[i][1] and m[i][0]<m[i][1]:
        ans+=m[i][0]*m[i][1]

print(ans%N)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = input().split()
listA = []
for i in range(len(As)):
    listA.append(int(As[i]))
ans = 0
for i in range(len(listA) - 1):
    for j in range(i + 1, len(listA)):
        if listA[i] != listA[j]:
            ans += listA[i] * listA[j]
print(ans % 1000000007)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
sum = 0
m = 10**9+7

for i in range(n):
  sum = (sum+a[i])%m

#sum = sum%m
#sum = sum*sum
ans = 0
for i in range(n):
  ans = (ans + sum*a[i])%m
  ans = (ans - a[i]*a[i])%m
ans = int((ans/2)%m)

print(ans)

Submission status: Wrong Answer

Solution code:
# cook your dish here
n=int(input())
a = list(map(int,input().split()))
sum = 0
sq = 0
mod = 1000000007
for i in range(len(a)):
    sum += a[i]
    sq += a[i]*a[i]
    sum = sum%mod 
    sq = sq%mod
ans = (sum*sum - sq + mod)%mod
print(int(ans/2))

Submission status: Wrong Answer

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

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

for i in range(N-1):
  JM =0
  for j in range(i+1,N):
    sum = sum - A[i]
    M += A[i] * sum
    if M > 10 ** 9 + 7:
      M = M % (10 ** 9 + 7)
print(M)

Submission status: Wrong Answer

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

sum = 0
for i in a:
    sum += i

sum = sum * sum

for j in a:
    sum = (sum - j*j) % 1000000007

print(int(sum/2))

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7

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

ans = 0
ans = sum(a) * sum(a) % MOD
ans -= sum(map(lambda x:x * x,a)) % MOD
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + MOD) // 2)

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline

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

suma = sum(A)
a = (suma ** 2)

b =0
for i in range(n):
  b += A[i]**2

ans = (a-b)/2
answer = int(ans)

answer = answer % (10**9 +7)

#print(a)
#print(b)
print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(float, input().split()))
S = sum(A)
result = 0
mod = 10 ** 9 + 7
for a in A:
  S -= a
  result += a * S
  result %= mod
print(result)

Submission status: Wrong Answer

Solution code:

def pro(A, n):
    prr = 0
    for i in range(n):
        for j in range(i + 1, n):
            prr = prr + A[i] * A[j]
    return prr


if __name__ == "__main__":
    u=0
    u=int(input())
    A = list(map(int,input().split()))
    n = len(A)



    print(pro(A, n))

Submission status: Wrong Answer

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

out = (sum(As)**2 - sum([a**2 for a in As]))/2
string =  str(out % (10**9+7))
print(string[0:len(string)-2])

Submission status: Wrong Answer

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

ans = 0
s = 0

def mod(x):
    return int(x % (1e+9 + 7))

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

    ans = mod(ans) 

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    A = nl()
    mod = 10 ** 9 + 7
    s = sum(A) % mod
    q = sum([a ** 2 for a in A]) % mod
    ans = (((s * s) % mod - q) % mod) / 2
    print(int(ans % mod))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = (x**2 - y)/2

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

print(int(ans))

Submission status: Wrong Answer

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

MOD = 1000000007

sum_all = 0
for i in range(len(a)):
    sum_all += a[i]
#sum_all %= MOD
sum = 0
#print(sum_all)
for i in range(len(a)):
    X = (sum_all - a[i])
    Y = a[i]
    sum += (X*Y/2)%MOD
print(int(sum)%MOD)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7
    s = sum(A)
    ans = 0
    for i in range(n):
        print(ans)
        s -= A[i]
        ans += A[i]*s
    print(ans%mod)


if __name__ == '__main__':
    main()

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 = acinput()

s1 = 0
for i in range(N):
    s1 += a[i]
    s1 %= K

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools as it

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

combinations_lis = list(it.combinations(a, 2))
print(combinations_lis)

sum = 0
for i in range(len(combinations_lis)):
    sum += combinations_lis[i][0] * combinations_lis[i][1]
print(sum % (10 ** 9 + 7))

# sum = 0
# for i in range(n):
#     sum += 1 / a[i]
#print(sum)

# ans = int(sum * np.prod(a))
# print(ans % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
sum = 0
m = 10**9+7

for i in range(n):
  sum = (sum+a[i])%m

#sum = sum%m
#sum = sum*sum
ans = 0
for i in range(n):
  ans = (ans + sum*a[i])%m
  ans = (ans - a[i]*a[i])%m
ans = int(ans/2)
ans = ans%m

print(ans)

Submission status: Wrong Answer

Solution code:
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 += A[i] * A[i]
print(int((array_sum_square -
       individual_square_sum) / 2) % (7 + 10 ** 9))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
l = 1

for i in range(N):
    for j in range(l,N):
        ans += an[i] * an[j]
    l +=1
print(ans)

Submission status: Wrong Answer

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

e = 1000000007
X = sum([i for i in int_list])
square_sum = sum([i**2 for i in int_list])%e
square = (X**2)%e
ans = int((square-square_sum))
ans = int(ans%e)
print(int(ans/2))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())), dtype=np.int64)
mod = 10**9 + 7

answer = 0
for i in range(N):
    answer = answer % mod +  A[i] % mod * (A[i+1:] % mod).sum() % mod

print(answer)

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))

  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  ans = ans % (10**9+7)
  for a in AA:
    aa = a**2
    aa = aa % (10**9+7)
    ans -= aa
  ans = ans % (10**9+7)
  if ans<=0:
    ans += 10**9+7
  print(int(ans/2))
solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = tuple(map(int,input().split()))
MOD = 10**9+7

s = 0
for ai in a:
  s += ai
  s %= MOD
ans = 0
for ai in a:
  ans += ai*(s-ai)
  ans %= 10**9+7
print((ans//2)%(10**9+7))

Submission status: Wrong Answer

Solution code:
n = int(input())
alist = list(map(int,input().split()))
wa = sum(alist) % (10**9 + 7)
answer = 0
for i in range(n):
    atai = 0
    if wa - alist[i] < 0:
        atai = wa - alist[i] + 10**9 + 7
    else:
        atai = wa - alist[i]
    answer += atai * alist[i]
    answer = answer % (10**9 + 7)
print(int(answer/2))

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  AA = list(map(int,input().split()))

  ans = 0
  for a in AA:
    ans += a
  ans = ans % (10**9+7)
  ans = ans**2
  ans = ans % (10**9+7)
  for a in AA:
    aa = a**2
    aa = aa % (10**9+7)
    ans -= aa
  ans = ans % (10**9+7)
  if ans<0:
    ans += 10**9+7
  print(int(ans/2))
solve()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    ans = 0
    sa = list(set(a))
    for i,item in enumerate(sa):
        for j,jtem in enumerate(sa):
            if j<i:
                continue
            else:
                if j==i and l[item]==1: continue
                ans += (item*jtem*l[item]*l[jtem])%mod
                ans %= mod
    print(ans)
    return

if __name__=='__main__':
    n = I()
    a = list(IL())
    #n = 2*10**5
    #a = [10**9]*n
    l = Counter(a)
    mod = 10**9 + 7
    solve()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array([int(x) for x in input().split()])

ans = (sum(a)**2 - sum(a*a)) % (10**9+7) / 2

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
import sys,collections
from sys import stdin, stdout  
#MAXN = 10000001

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip() 
def input(): return sys.stdin.readline().strip()
#spf = [0 for i in range(MAXN)] 
def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w') 
def is_subsequence(x, y):
    """Test whether x is a subsequence of y"""
    x = list(x)
    for letter in y:
        if x and x[0] == letter:
            x.pop(0)

    return not x    
def sieve(): 
	spf[1] = 1
	for i in range(2, MAXN): 
		spf[i] = i 
	for i in range(4, MAXN, 2): 
		spf[i] = 2

	for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
		if (spf[i] == i): 
			for j in range(i * i, MAXN, i): 
				if (spf[j] == j): 
					spf[j] = i 
def getFactorization(x): 
	ret = list() 
	while (x != 1): 
		ret.append(spf[x]) 
		x = x // spf[x] 

	return ret 
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    ind,floor = -1,-1
    while left <= right:
        mid = (left + right) // 2
        '''if A[mid] == x:
            return mid'''
        if x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            ind=mid
            left = mid + 1
            
    return ind
def check(st) : 
  
    # Compute sum of digits 
    n = len(st) 
    digitSum = 0
      
    for i in range(0,n) : 
        digitSum = digitSum + (int)(st[i]) 
  
    # Check if sum of digits 
    # is divisible by 9. 
    return (digitSum % 9 == 0)     
def isPowerOfTwo(n): 
    if (n == 0): 
        return False
    while (n != 1): 
            if (n % 2 != 0): 
                return False
            n = n // 2
            
              
    return True
def kitte(n):
	c=0
	while(n!=0):
		n=n//2
		c+=1
	return c	
def aa(b,c):
	m=min(b,c)
	b-=m
	c-=m
	if(c>0 and b>0):
		return(m+((b+c)//3))
	else:
		return(m)
def bb(a,c):
	m=min(a,c)
	a-=m
	c-=m
	if(c>0 and a>0):
		return(m+((a+c)//3))
	else:
		return(m)
def cc(b,a):
	m=min(b,a)
	b-=m
	a-=m
	if(a>0 and b>0):
		return(m+((b+a)//3))
	else:
		return(m)		
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		
#file()
#sieve() 
mod=(10**9)+7	
def main():
		n=int(input())
		l=get_array()
		s=0
		s=int(findProductSum(l,n))
		print(s%mod)		

	



	

	
			


		




		






		







			



	

	




	





















	




















		
			


		

			

		





			

	























				

	















	

	










if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

p = 0
for i in range (int(n)): 
    for j in range ( i+1,int(n)): 
        p = p + x[i] * x[j] 
print(p)

Submission status: Wrong Answer

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

s_1 = 0
s_2 = 0
for i in range(n):
    s_1 += a[i]
    s_2 += a[i] * a[i]
s = (s_1 * s_1 - s_2) / 2
print(int(s % (pow(10, 9) + 7)))

Submission status: Wrong Answer

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

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
class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    __str__ = lambda self:str(self.x)
    __repr__ = __str__
    __int__ = lambda self: self.x
    __index__ = __int__

    __add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
    __sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
    __mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
    __pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
    __truediv__ = lambda self, other: ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))
    __floordiv__ = lambda self, other: ModInt(self.x // ModInt(other).x)
    __radd__ = lambda self, other: ModInt(other + self.x)
    __rsub__ = lambda self, other: ModInt(other - self.x)
    __rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
    __rmul__ = lambda self, other: ModInt(other * self.x)
    __rtruediv__ = lambda self, other: ModInt(other * pow(self.x, MOD - 2, MOD))
    __rfloordiv__ = lambda self, other: ModInt(other // self.x)

    __lt__ = lambda self, other: self.x < ModInt(other).x
    __gt__ = lambda self, other: self.x > ModInt(other).x
    __le__ = lambda self, other: self.x <= ModInt(other).x
    __ge__ = lambda self, other: self.x >= ModInt(other).x
    __eq__ = lambda self, other: self.x == ModInt(other).x
    __ne__ = lambda self, other: self.x != ModInt(other).x


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

A = [ModInt(a) for a in A]

A_d = [a * a for a in A]

res = sum(A)**2 - sum(A_d)

res = int(str(res))
res //= 2
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+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

ans = (int(findProductSum(a, n)))%mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = 1000000007

sum_all = 0
for i in range(len(a)):
    sum_all += a[i]
#sum_all %= MOD
sum = 0
#print(sum_all)
for i in range(len(a)):
    X = (sum_all - a[i])
    Y = a[i]
    sum += (X*Y)%MOD
print(int(sum)%MOD // 2)

Submission status: Wrong Answer

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

out = (sum(As)**2 - sum([a**2 for a in As]))/2
print(out % (10**9+7))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
num =0
for i in A:
  for j in A:
    if(i < j):
      num=num + i*j
else:
  print(num % 1000000007)

Submission status: Wrong Answer

Solution code:
def solution(A):
    ret = 0
    sA = [0] *len(A)
    sA[0] = A[0]
    for i in range(1, len(A)):
        sA[i] = (sA[i-1] + A[i]) % (10**9 + 7)
    for i in range(len(A) - 1):
        v = A[i] * (sA[-1] - sA[i] if sA[-1] > sA[i] else sA[-1] + 10**9 + 8 - sA[i])
        v = v % (10**9 + 7)
        ret += v
        ret = ret % (10**9 + 7)
    return ret

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(int(y) for y in input().split())
b=[]
# c=[]
for i in range(n):
    for j in range(i + 1, n):
    # print(a[i])
        b.append(((a[i]%(10**5))*(a[j]%(10**5))%((10*9)+7)))

# for i in range(n):
#     for j in range(i+1,n):
#         # print(a[i]*a[j]%((10**9)+7))
#         c.append((b[i]*b[j])%((10**9)+7))
print(sum(b)%((10**9)+7))