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 numpy as np
import itertools
N = input()
A = list(map(int,input().split()))
mod = 10**9+7
s = 0
def seki(a, b):
    return (a * b) % mod
  
for pair in itertools.combinations(A, 2):
  s += seki(pair[0],pair[1])

print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split(' ')
b=[]
for x in a:
    b.append(int(x))
su=0
for t in b:
    su+=t
    
su=su**2
pas=0
for t in b:
    pas+=t*t
er=su-pas
er/=2
print(int(er%1000000007))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
As = np.array(list(map(int, input().split())))
m = 10**9 + 7
result = 0
a = (As.sum() ** 2)
b = (As ** 2).sum()
print(int(str((a - b)%m / 2).split(".")[0]))

Submission status: Wrong Answer

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

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

m = 10**9+7
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:
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
    if ans<0:
      ans += 10**9+7
    if ans<0:
      ans += 10**9+7
  ans = ans % (10**9+7)
  print(int(ans/2))
solve()

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

s = int(0)
r = int(0)
for a in A:
    s = int(s + a)
    r = int(r + a * a)

print(int(((s * s - r) % MOD) / 2))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
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:
# -*- coding: utf-8 -*-
N= int(input())
A= list(map(int,input().split(' ')))
 
ans = 0
for i in range(len(A)-1):
  for j in range(i+1, len(A)):
    ans += A[i]*A[j]
 
print(ans)

Submission status: Wrong Answer

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

mod = 1000000007
ans = 0
A = 0
B = 0
for i in range(n):
    A += a[i]
    B += pow(a[i],2)
ans = (pow(A,2) - B) % mod / 2
print(int(ans))

Submission status: Wrong Answer

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

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=(s+a[i])%(10**9+7)
    v=(v+a[i]**2)%(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:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    A  = [int(i) for i in input().split()]
    #N = 100000
    #A = [i for i in range(1,100000)]
    sum_a = sum(A)% 1000000007
    ans = 0
    for i in range(N):
        #for j in range(i+1,N):
        #sum_a = sum(A[i+1:N]) % 1000000007
        ans = (ans + (sum_a-A[i])*A[i] ) % 1000000007
            #print(A[i],A[j],ans)
    print(ans//2)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
mod = 1000000007
N = int(input())
A = list(map(int,input().split()))
sum_a = sum(A)
ans = 0
for a in A:
    ans += a*(sum_a-a)
    #print(sum_a-a)
    ans %= mod
    
print(ans//2)

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(ans)

Submission status: Wrong Answer

Solution code:
import itertools

N = int(input())
An = [int(x) for x in input().split(" ")]
pair = list(itertools.combinations(An, 2))

sum = 0
for i in range(len(pair)):
    sum += (pair[i][0] * pair[i][1])%1000000007
print(sum)

Submission status: Wrong Answer

Solution code:
import itertools
import numba
from numba import jit, i8


n = int(input())
a = list(map(int, input().split()))
MOD = 10**9 + 7
ans = 0

for i, val in enumerate(a):
    temp = val * sum(a[i + 1:])
    ans += temp % MOD

print(ans)

'''
@jit
def calc(lis):
    ans = 0
    num = len(lis)
    for i in range(num):
        for j in range(i + 1, num):
            temp = (lis[i] * lis[j]) % MOD
            ans += temp

    return ans


aa = calc(a)
print(aa)
'''

'''
for i in itertools.combinations(a, 2):
    temp = (i[0] * i[1]) % MOD
    ans += temp

print(ans)
'''

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！
n = I()
a = LI()
s = sum(a)
ans = 0
for j in range(len(a)):
    ans += (a[j]%mod)*((s - a[j])%mod)
    ans = ans%mod
print(ans//2)

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 = ans+(a[i])*(a[j])
    if ans>1000000007:
      ans /= 1000000007

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

Submission status: Wrong Answer

Solution code:
# Efficient python 3 program to find sum 
# pair products in an array. 
mod=1000000007
# 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 
if __name__ == '__main__': 
    n=int(input())
    a=input().split()
    for i in range(n):
        a[i]=int(a[i])
    ans=int(findProductSum(a,n))
    ans%=mod
    print(ans)

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
    if aa>ans:
      aa = aa % (10**9+7)
    ans -= aa
    if ans<0:
      ans += 10**9+7
  ans = ans % (10**9+7)
  print(int(ans/2))
solve()

Submission status: Wrong Answer

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

for i,j in itertools.product(range(n-1), range(1,n)):
    if i < j:
        ans += (a[i]*a[j])
        print(a[i],a[j])

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

Submission status: Wrong Answer

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


def main():
    import numpy as np

    N, *A = map(int, open(0).read().split())
    A = np.array(A)
    print(sum([np.sum(A[i] * A[i + 1 :]) for i in range(N)]) % (10 ** 9 + 7))


main()

Submission status: Wrong Answer

Solution code:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    sumnation = 0
    for i in A:
        sumnation += (i % mod)
        sumnation %= mod

    ans = pow(sumnation, 2, mod)
    for i in A:
        ans -= pow(i, 2, mod)
        while ans < 0:
            ans += mod
    ans //= 2
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

from itertools import combinations

num = 10**9 + 7
ans = 0

B = []
b = 0
for i in reversed(A[1:]):
    b += i
    B.append(b)
B.reverse()
print(B)
for x, y in zip(A[:-1], B):
    ans += x*y
    ans %= num
print(ans)

Submission status: Wrong Answer

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

ans = 0
s = 0

def mod(x):
    return 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:
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))


if __name__ == '__main__':
    main()

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
#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) :
    ans += a[i]*c[i]
    #print(a[i],c[i],ans)
print(int(ans%mod))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
 
def findProductSum(A, n): 
	
	
	array_sum = 0
	for i in range(0, n, 1): 
		array_sum = array_sum + A[i]
	array_sum=array_sum%1000000007

	
	array_sum_square = array_sum * array_sum 

	array_sum_square=array_sum_square%1000000007
	individual_square_sum = 0
	for i in range(0, n, 1): 
		individual_square_sum += A[i] * A[i] 
	individual_square_sum=individual_square_sum%1000000007
	
	return ((array_sum_square -
			individual_square_sum) / 2)%1000000007


if __name__ == '__main__': 
	n=int(input())
	A = list(map(int,input().split()))
	#n = len(A) 
	print( int(findProductSum(A, n)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

for i in range(2,n+1):
  a[-i] += a[-i+1]

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

Submission status: Wrong Answer

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

sum=0;
for i in range(0, size):
  for j in range(i+1, size):
    sum = sum + int(arr[i])*int(arr[j])
  

print(sum)

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

mod=10**9+7

sumA=sum(A)%mod

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

ans=ans//2
print(ans%mod)

Submission status: Wrong Answer

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

for i in range(n):
    for l in range(n):
        if i != l:
            k += a[i] * a[l]

print(k / 2)

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 += pow(a, 2, MOD)%MOD
    ans += a%MOD
ans = (((pow(ans, 2, MOD) - AA)%MOD)//2)%MOD
print(ans)

Submission status: Wrong Answer

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

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

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

print(ans)

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

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


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:
import numpy as np
import itertools
N = input()
A = list(map(int,input().split()))
mod = 10**9+7
s = 0
for pair in itertools.combinations(A, 2):
  s = s + (pair[0]*pair[1] % mod)
print(s)

Submission status: Wrong Answer

Solution code:
n=int(input())
ar=[int(i) for i in input().split()];
ar_sum=0
for i in range(0, n):
    ar_sum += ar[i]

ar_sum_sqr = (ar_sum * ar_sum)
s=0
for i in range(n):
    s+=(ar[i]*ar[i])

print(str(int((ar_sum_sqr - s) / 2)%1000000007))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
s = 0

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

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

    ans = mod(ans) 

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numba
from numba import njit, b1, i4, i8, f8
import numpy as np  # noqa

N = int(input())
A = np.array([int(x) for x in input().split()], dtype=np.int64)
s = 0
for i in range(N):
    s += A[i]


def main(A, s):
    ans = 0
    for i in range(N - 1):
        s -= A[i]
        ans = (ans + A[i] * s) % (10**9 + 7)
    return ans


print(main(A, s))

Submission status: Wrong Answer

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

print("A:",A)

Sum = 0
Asum = sum(A) % 1000000007
for i in range(len(A) -1 ):
    b = A[i]
    Asum = Asum - b
    if Asum < 0:
        Asum = Asum + 1000000007
    Sum = (Sum + Asum * b) % 1000000007

print(Sum)

Submission status: Wrong Answer

Solution code:
N = int(input())
alist = list(map(int, input().split()))
Sum_a = 0
for i in range(N):
  Sum_j = 0
  for j in range(i+1, N):
    if alist[j] >= (1e9+7):
      Sum_j += int(alist[j] % (1e9+7))
    else:
      Sum_j += alist[j]
  if alist[j] >= (1e9+7):
    Sum_a += int(alist[i] % (1e9+7)) * Sum_j
  else:
    Sum_a += alist[i] * Sum_j
print(Sum_a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a =[int(x) for x in input().split()]
ans = 0
for index,i in enumerate(a):
    for j in a[index+1:]:
        ans +=  (i * j) % (10**9 + 7)
print(ans)

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])%mod
    array_sum_square = (array_sum * array_sum)%mod
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum = (individual_square_sum + (A[i] * A[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:
modulo=10**9+7
N=int(input())
array=[(int(x))%modulo for x in input().split()]
total=((sum(array))**2)%modulo
for i in array:
	total=((total-((i%modulo)**2)))%modulo
print(((total//2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(lambda x: int(x), input().split(' ')))

res = ((sum(A)**2 - sum(list(map(lambda x: x**2, A)))) / 2) % (10**9 + 7)

print(int(res))

Submission status: Wrong Answer

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

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,N):
    s += a[i]*a[j]
for i in range(N):
  s -= a[i]*a[i]

print(s)

Submission status: Wrong Answer

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

ans = 0
mod = 1e9+7

for i in range(n-1):
    for j in range(i+1,n):
        ans += (a[i]*a[j])%mod
        ans %= mod
print(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])%mod 
  
    # calcualting square of array sum 
    # (a1 + a2 + ... + an)^2 
    array_sum_square = (array_sum * array_sum)%mod
  
    # 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=findProductSum(l,n)
		print(s%mod)		

	



	

	
			


		




		






		







			



	

	




	





















	




















		
			


		

			

		





			

	























				

	















	

	










if __name__ == '__main__':
    main()

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
if __name__ == '__main__':
    n = int(input());
    ls = list(map(int,input().split()));
    print((int(findProductSum(ls, n)))%1000000007);

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
As = np.array(list(map(int, input().split())))
m = 10**9 + 7
result = 0
a = (As.sum() ** 2)
b = (As ** 2).sum()
print(int((a - b)%m / 2))

Submission status: Wrong Answer

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

sums = 0
for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        temp = a[i] * a[j]
        if temp < 10 ** 9:
            pass
        else:
            sums = (sums + (a[i] * a[j])) % (10 ** 9 + 7)

print(sums)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = (tmp*tmp-tmp2)/2

print(int(total%1000000007))

Submission status: Wrong Answer

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

for i in range(N):
    for j in range(i):
        if i != j:
            count = int(a[1][i])*int(a[1][j])+count
count = count % 100000007
print(count)

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 = sum%mo
sum_square = (sum**2)%mo
sum_2 = 0
l_1 = [(i*i)%mo for i in l]
for i in l_1:
    sum_2 += i
    sum_2 = sum_2%mo
t = (((sum_square - sum_2)%mo)//2)%mo
print(t)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
inf=10**9+7
import numpy as np
arr_a=np.array(a)
s=np.sum(arr_a)
norm=np.sum(arr_a**2)
x=(s**2-norm)//2
print(x%inf)

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(i+1, n):
        ans += a[i] * a[j]
        print("i, j, a[i], a[j] = {}, {}, {}, {}".format(i, j, a[i], a[j]))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
c = int(input())
a = list(map(int,input().split()))
n = 0
result = 0
for i in range(c):
    b = []
    b =b + a
    b.pop(n)
    result += sum(b) * a[n]
    n += 1
print(int(result/2%1000000007))

Submission status: Wrong Answer

Solution code:
# required function
def findProductSum(A, n):
    tmp = (10**9)+7

    # 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]
        individual_square_sum = individual_square_sum

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

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

print(findProductSum(a,n))

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

MOD = 10 ** 9 + 7
total = 0
s = sum(a)

for i in range(n):
    total += (a[i] * (s - a[i])) % MOD

print((total % MOD) // 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 + 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
n=int(input())
lst=list(map(int,input().split()))
x=findProductSum(lst,n)
print(x)

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(int(out % (10**9+7)))

Submission status: Wrong Answer

Solution code:
N=int(input())
S=list(input().split())
A=[int(n) for n in S]
ans=int(0)
for i in A:
    for j in A:
        ans += i*j
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    sumnation = 0
    for i in A:
        sumnation += (i % mod)
        sumnation %= mod

    ans = pow(sumnation, 2, mod)
    for i in A:
        ans -= i**2
        if ans < 0:
            ans += mod*(-ans // mod)
            if ans < 0:
                ans += mod
    ans //= 2
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def resolve():
    import math
    n = int(input())
    # a_n = [-1] * (n + 1)
    a_n = [-1]
    hoge = list(map(int, input().split()))
    a_n.extend(hoge)
    sum_ = 0
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            sum_ += (a_n[i] * a_n[j])
    print(int(sum_ % (10E08 + 7)))

resolve()

Submission status: Wrong Answer

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

res = numpy.cumsum(A)

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin, stdout,stderr
import time,math
from collections import defaultdict as dd
 
def pn(ob):stdout.write(str(ob))
def inp():return stdin.readline()

mod = 10**9 + 7

def main():
	n = int(inp())
	arr = list(map(int, inp().split()))

	tot = 0
	res = 0

	for x in arr:
		tot += x
		tot %= mod

	for x in arr:
		res = (res + (x * (tot - x)) % mod)%mod
	pn(res//2)
  
if __name__ == '__main__':
	main()
	
#n,m=map(int,input().split()) 
# for i in range(n):
#     t=int(stdin.readline()) # input using fast i/p method 
#     if t%m == 0:
#         stdout.write(str(t)+'\n') #input using fast o/p method
 
# take line of integers as input
# 	arr = list(map(int, inp().split()))

Submission status: Wrong Answer

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

sum1=0
sum2=0

for i in arr:
    sum1+=i
    sum2+=i**2

x=((sum1**2)%(10**9+7) - sum2%(10**9+7))%(10**9+7)

x=x//2
print(x)

Submission status: Wrong Answer

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