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:
import sys
import numpy as np
import math
import collections
import copy
import decimal
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

N = int(input())
An = list(map(int, input().split()))
An_s = collections.Counter(An)
total = 0
for k in An_s:
    total += k
ans = 0
for A, v in An_s.items():
    At = A * (total-A)*v
#     print(A, total, At, ans)
    ans = (ans+At) % (10**9+7)
#     print(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
ans = 0
mod = 1e9+7

N = int(input())
A = [int(num) for num in input().split()]

A_sum = sum(A)
A_squared = sum([num**2 for num in A])

ans = (A_sum**2 - A_squared)//2
ans = int(ans%mod)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[int(s) for s in input().split()]
ans=0
for i in range(N-1):
    for j in range(i+1,N):
        ans+=d[i]*d[j]
print(ans)

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_ls=list(map(int, input().split()))

a=(sum(A_ls))**2
b=0
for i in A_ls:
	b+=(i**2)

c=int((a-b+0.5)/2)
print(c%(10**9+7))
#print(b)

# 2darray [[0] * 4 for i in range(3)]
# import itertools

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
    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()))
num=0
for i in a:
  for j in a[n:i-1:-1]:
    num=num+(i*j)
else:
  print(num % 1000000007)

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):
    s -= h[i]
    ans += h[i] * s
ans = ans % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

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

# required function 
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 
mod = 1e9+7
if __name__ == '__main__': 
	n = int(input()) 
	l = list(map(int, input().split())) 
	print(int(findProductSum(l, n)%mod)) 
	
# This code is contributed by 
# Sahil_Shelangia

Submission status: Wrong Answer

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

for k in range(n):
    if a[k]>10**8:
        a[k]=(10**9+7)-a[k]
    
    
b=[]
for i in range(n-1):
    for j in range(i+1,n):
        b.append(a[i]*a[j])
print(sum(b)%(10**9+7))

Submission status: Wrong Answer

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

m = 10 ** 9 + 7
def main():
    r = 0
    for nn in range(n):
        r += a[nn]
    print(r)
    return

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]
a_sum = sum(a_list)

total = 0
for i in range(0, len(a_list)-1):
    total += a_list[i] * (a_sum - a_list[i])
total = total % max
print(total)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))
sum = 0
mo = 1000000007
for i in range(n):
    sum += l[i]
    # sum %= mo

sum_square = ((sum%mo)**2)%mo
sum_2 = 0

for i in l:
    sum_2 += (i*i)%mo
    # sum_2 %= mo

t = (((sum_square - sum_2)%mo)//2)
print(t)

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] 
print(int(((array_sum_square - individual_square_sum) / 2) % 1000000007))

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 %= (10**9+7)
s = s**2
s %= (10**9+7)
 
t = 0
for i in range(N):
  t += (A[i]**2 % (10**9+7))
t %= (10**9+7)
 
ans = (s-t) % (10**9+7)
print(int(ans/2))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(x) for x in input().split(" ")]
res = 0
for i in range(0, len(nums)):
	for j in range(i + 1, len(nums)):
		res += (nums[i] * nums[j]) % 1000000007
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
summ1 = 0
answer = 0
temp = 0
summ2 = 0
summ3 = 0
for i in range(N):
    summ1 += A[i]
for l in range(N):
    summ3 += A[l]
    summ2 += A[l]*(summ1-summ3)
    print(summ3)
    print(summ2)
answer = summ2 % 1000000007
print(answer)

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:
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):
    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())
t=np.array(input().split(' '))
num=np.zeros(n)

for a in range(n):
  num[a]=int(t[a])
print(num*num)
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:
N = int(input())
A = list(map(int, input().split()))
 
s = 0
for i in range(N):
  s += A[i]
  s %= (10**9+7)
s = s**2
s %= (10**9+7)

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

ans = (s-t) % (10**9+7)
print(int(ans/2))

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n):
    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = (array_sum%1000000007+ A[i]%1000000007)%1000000007

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

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

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

n = int(input())
arr = input()   # takes the whole line of n numbers
l = list(map(int,arr.split(' ')))


print(((int)(findProductSum(l,n)))%1000000007)

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
ss=0
s=0
for i in range(n):
    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()))
k = 0
num = sum(a)
import math

for i in range(n):
    k = k + a[i] * num - a[i] ** 2

x = (k / 2) % (10 ** 9 + 7)
print(math.floor(x))

Submission status: Wrong Answer

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

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):
            ans+=A[i]*A[j]

ans = ans
print(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)):
    if lst[i] not in d_lst:
        for j in range(i+1,len(lst)):
        # print(i,j)
            a = lst[i] * lst[j]
            if lst[j] in d_lst:
                continue
            else:
                if lst[i] == lst[j]:
                    d_lst.append(lst[j])
                    count += a
                else:
                    count += a

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

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n):
    array_sum = 0
    # x = (10 ** 9) + 7
    # for item in A:
    #     item = item%x
    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 (array_sum_square -
            individual_square_sum) / 2

if __name__ == '__main__':
    n = int(input())
    A = list(map(int,input().split()))
    x = (10 ** 9) + 7
    print(int(findProductSum(A, n))%x)

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())
x  = 0
y = 0
mod = 1000000007 
inp = list(map(int,input().split())) 
for i in inp:
    x += i
    y += (i*i)

x = x*x

res = (x-y)/2
#res =  res%mod
res = int(res%mod)
print(res)

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
m = 10**9 + 7
result = 0
b = 0
for i in range(N):
  b += pow(As[i], 2, m)
a = pow(sum(As), 2, m)
print(int(str((a - b)%m / 2).split(".")[0]))

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) /2
    ans = ans % m

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

print(int(ans))

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 29 20:26:17 2020

@author: wiste
"""

#import numpy as np

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

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

ans = sum([x*y for (x, y) in zip(A, B)])


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]**2
    sum2%=mod
ans=((sum1**2)-sum2)%mod/2
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
mod = 1000000007
sum_A = (sum(A)**2) % mod
B = map(lambda x: (x**2)% mod,A)
sum_B = sum(B) % mod
answer = int(((sum_A-sum_B)/2)%mod)
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
s = 0
a = np.array(list(map(int, input().split())))
for i in range(len(a)-1):
  s_tmp = np.sum(a[i+1:len(a)])
  s += a[i] * s_tmp
print(s % 1000000007)

Submission status: Wrong Answer

Solution code:
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]

print(sum(a_list))
total = 0
for i in range(0, len(a_list)-1):
    total += a_list[i] * sum(a_list[i+1:])
total = total % max
print(total)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))
sum = 0
mo = 1000000007
for i in range(n):
    sum += l[i]
    sum %= mo

sum_square = ((sum%mo)**2)%mo
sum_2 = 0

for i in l:
    sum_2 += (i*i)%mo
    sum_2 %= mo

t = (((sum_square - sum_2)%mo)//2)
print(t)

Submission status: Wrong Answer

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

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

print(ans % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])
sum = A.sum()
sum2 = int((A**2).sum())
ans = int(((A.sum())**2 - sum2)/2) % (10**9+7)
print(ans)

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 (array_sum_square - 
            individual_square_sum) / 2
      
  
print(int(findProductSum(A,n) % ((10**9)+7)))

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())
nums = list(map(int, input().rstrip().split()))

counter = 0

for i in range(n):
    for j in range(n):
        if (0 <= i < j):
            counter = counter + (nums[i] * nums[j])
            
print(counter)

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 - sum([x**2 for x in A])
print(int(y / 2) % mod)

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)):
    if lst[i] in d_lst:
        continue
    for j in range(i+1,len(lst)):
    # print(i,j)
        a = lst[i] * lst[j]
        if lst[j] in d_lst:
            continue
        else:
            if lst[i] == lst[j]:
                d_lst.append(lst[j])
                count += a
            else:
                count += a
    
if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

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
    ans += A[i - 1] * tsum
    ans %= nmod

print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
B = [0]*N

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
aa=(sum(a)*sum(a))
s=0
for i in a:
    s+=(i**2)
aa=(aa-s)/2
aa%=1000000007
print(int(aa))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = list(map(int, input().split()))
S = 0
T = 0
for i in range(N):
  S += As[i]
  T += As[i] * As[i]
print(int(((S*S - T) / 2))% 1000000007)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
#code
from itertools import combinations
n=1
while n>0:
    n-=1
    s=0
    k=int(input())
    l=list(map(int,input().split()))
    p=list(combinations(l,2))
    for i in p:
        t=list(i)
        s=s+(t[0]*t[1])
    print(s)

Submission status: Wrong Answer

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

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

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

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 ** 2

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

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
a = np.array(readline().split(), dtype=np.uint64)
r = np.cumsum(a[::-1])[::-1]
r &= MOD
x = a[:-1] * r[1:]
x %= MOD
ans = int(np.sum(x) % MOD)
print(ans)

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)*sum(a)-y)/2)


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

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = stdin.readline().rstrip().split()[0]
A = [int(x) for x in stdin.readline().rstrip().split()]

print(int(((sum(A)**2 - sum([a**2 for a in A])) / 2) % (10**9 + 7)))

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) % K
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 itertools

n = int(input())
a = [int(x) for x in input().split()]
s = 0
for (i, j) in list(itertools.permutations(a, 2)):
    if i >= j:
        continue
    s += i * j
print(s % 1000000007)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = 1000000007
dict = {}
sum_all = 0
for i in range(len(a)):
    sum_all += a[i]
    if str(a[i]) not in dict:
        dict[str(a[i])]  = 1
    else:
        dict[str(a[i])]  += 1
#sum_all %= MOD
sum = 0
#print(sum_all, dict)
for i in range(len(a)):
    X = (sum_all - a[i])
    Y = a[i]
    sum += (X*Y)
print(int(sum/2)%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n):
    # calculating array sum (a1 + a2 ... + an)
    array_sum = 0
    for i in range(0, n, 1):
        array_sum = (array_sum%1000000007+ A[i]%1000000007)%1000000007

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

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

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

n = int(input())
arr = input()   # takes the whole line of n numbers
l = list(map(int,arr.split(' ')))


print((int)(findProductSum(l,n))%1000000007)

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 = round((seihokei-shoseihokei)/2)
answer = answer % (10**9+7)
print( math.floor(answer) )

Submission status: Wrong Answer

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

for i in range(N):
  for j in range(i+1,N):
    sum += (data[i]*data[j]) % (1000000007)
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = input().split()
B = [0]*N

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
num=input().split()
sq=[]
for i in range(n):
  num[i]=int(num[i])
  sq.append(num[i]*num[i])
total=sum(num)
total=total*total
sqtotal=sum(sq)
ans=(total-sqtotal)/2
print(int(ans%1000000007))

Submission status: Wrong Answer

Solution code:
d = 10 ** 9 + 7
n = int(input())

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


s = 0
for i in range(n):
    s += a[i]
    s %= d

ans = 0
for i in range(n):
    b = a[i] * (s - a[i])
    ans += b
    ans %= d 

ans //= 2

print(ans)

Submission status: Wrong Answer

Solution code:
def findProductSum(A, n):
    array_sum = 0
    x = (10 ** 9) + 7
    for item in A:
        item = item%x
    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 (array_sum_square -
            individual_square_sum) / 2

if __name__ == '__main__':
    n = int(input())
    A = list(map(int,input().split()))
    x = (10 ** 9) + 7
    print(int(findProductSum(A, n))%x)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
a = list(map(int,input().split()))
ans = 0
m = 10**9 + 7
for item in itertools.combinations(a, 2):
    ans += (item[0] * item[1]) % m
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
ans = 0
A = list(map(int,input().split()))
a = np.array(A)

for i in range(N-1):
  ans += a[i]*(a[i+1:N].sum())
    
print(ans%((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:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
mod=int(1e9)+7
def SumOfProductOfAllPairArrayElement(arr):
    su=0
    ans=0
    for x in arr:
        su=(su%mod+(x)%mod)%mod
    for x in arr:
        ans=(ans%mod+(x%mod*(su-x)%mod)%mod)%mod
    return (ans//2)%mod

 
def main():
    n=int(input())
    vals = list(map(int,input().split(" ")))
    print(SumOfProductOfAllPairArrayElement(vals))


#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

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]
    if tsum > nmod:
        tsum %= nmod
    ans += A[i - 1] * tsum
    if ans > nmod:
        ans %= nmod

print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
ar = input().split()
ar = [int(x) for x in ar]
count = 0
sum = 0
mod = 10**9+7
for i in range(len(ar)):
    for j in range(i+1,len(ar)):
        if count >= n:
            break
        sum = (sum + (ar[i]*ar[j])%mod)%mod
        count+=1
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
n_list = [int(i) for i in input().split()]
ans = 0
mod = 10 ** 9 + 7
num_list = [n % mod for n in n_list]

while len(num_list) > 1:
    x = num_list[0]
    num_list.remove(x)
    ans += (x * (sum(num_list) % mod)) % mod

# for i in range(n-1):
#     for j in range(i+1,n):
#         ans += (num_list[i] * num_list[j]) % mod
#         ans = ans % mod

print (ans)

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 % 1000000007

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

print(int(sum/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
al = list(map(int, input().split()))
s = sum(al)
ss = 0
for a in al:
    ss += a*a
print(int((s*s-ss)/2)%(10**9+7))

Submission status: Wrong Answer

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

total = 0
for i in range(n - 1):
  temp = []
  for j in range(i + 1, n):
    temp.append((a[i]*a[j]) % (10**9 + 7))
    total += sum(temp) % (10**9 + 7)

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

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
# for i in range(n-1):
#     for j in range(i+1,n):
#         ans += A[i]*A[j]
#         ans %= mod
sum = 0
for i in A:
    sum += i
sum %= mod    

# ans = sum * sum
# for j in A:
#     ans -= j * j
#     ans %= mod
# ans //= 2    

ans = 0
for i in range(n):
    ans += A[i] * (sum-A[i])
    ans %= mod
ans //= 2
print(ans)

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 += a[i]
    array_sum%=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+MOD) / 2
print(int(ans%MOD))

Submission status: Wrong Answer

Solution code:
def resolve():
    import numpy as np

    n = int(input())
    A = np.asarray(list(map(int, input().split())))
    s = sum(A)
    print(((s**2 // 2) - (sum(A**2)//2)) % (10**9 + 7))

resolve()

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*s1) % K
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:
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)*sum(a)-y)/2)

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

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7

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 (array_sum_square - individual_square_sum) / 2

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