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

ans = 0
s = 0

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

    ans = ans % (1e+9 + 7)
    s = s % (1e+9 + 7)

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

MOD = (10**9)+7
a_sum = 0
ans = 0
for i in range(n-1):
    a_sum += a_list[n-i-1]
    print(a_sum)
    ans += a_sum * a_list[n-i-2]
    ans = ans % MOD

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
MOD = 1000000007


def product(ar, n):
    result = 1
    for i in range(0, n):
        result = (result * ar[i]) % MOD
    return result


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

print(product(a, n))

Submission status: Wrong Answer

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

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

minustotal = sum(doubleA)

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

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)%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)%mod
ans = int(findProductSum(a, n))
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools

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

result = 0
for aa in itertools.combinations(aaa, 2):
  result += aa[0] * aa[1]
  
print(result % 10 ** 9 + 7)

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.int32)
s = sum(A) % (10**9 + 7)


@njit((i4[:], i4, ), cache=True)
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:
n=int(input())
a=list(map(int,input().split()))
ans=0
p=10**9+7
for i in range(n):
    ans=(ans+a[i]**2)%p
am=sum(a)%p
print(((am**2-ans)//2%p))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
def selfmult(x):
    return x**2
dot=(sum(A)**2-sum(map(selfmult,A)))/2
print(int(dot)%(1000000007))

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])
  S += A[i]
  B += (A[i]*A[i])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in a:
    for j in a:
        if i < j:
            s += i * j

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 (nums[i] < nums[j]):
            counter += nums[i] * nums[j]
            
print(counter)

Submission status: Wrong Answer

Solution code:
# C - Sum of product of pairs

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

s = 0
for i in range(0,(len(a)-1)):
	for j in range((i+1),len(a)):
		s = s+(a[i]*a[j])
print(s)

Submission status: Wrong Answer

Solution code:
modulo=10**9+7
N=int(input())
array=[int(x) for x in input().split()]
total=((sum(array))**2)%modulo
for i in array:
	total=(total-i**2)%modulo
print((total//2))

Submission status: Wrong Answer

Solution code:
num = int(input())
nums = list(map(lambda x: int(x), input().split()))

ans = sum(nums)**2 - sum(map(lambda x: x**2, nums))
ans = ans / 2
  
print(int(ans%(10**9+7)))

Submission status: Wrong Answer

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

    mod = 10**9 + 7

    tmp = [0] * N

    s = 0
    for i in range(N):
        tmp[- i - 1] = s
        s += A[-i - 1]

    print(tmp)

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

    print(ans % mod)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in a:
    for j in a:
        if i > j:
            s += i * j

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

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

print(int(findProductSum(a, n) % (1e9 + 7)))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
a = 0
S = 0
for i in range(N):
    for j in range(i+1,N):
        a = A[i]*A[j]
        S += a
p = S%10000000007
print(p)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(e) for e in input().split()]
sum = 0
for i in A :
    for j in A:
        if i == j : break
        sum = sum + i*j
print(sum%1000000007)

Submission status: Wrong Answer

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

s, t = 0, 0
for i in range(N):
  s += A[i]
  t += A[i]**2
s = s**2

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

Submission status: Wrong Answer

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

ans = 0
s = 0

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

    ans = ans % (1e+9 + 7)

print(int(ans))

Submission status: Wrong Answer

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

AA = sum(A)
ans = 0
mod = 10**9 + 7
for i in range(n):
    ans += (A[i] % mod * (AA - A[i]) % mod) % mod
if ans//2 < mod:
    print(ans % mod//2)
else:
    print((ans//2) % mod)

Submission status: Wrong Answer

Solution code:
m=1e9+7

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

	array_sum_square = (array_sum * array_sum )%m

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

	return (array_sum_square -
			individual_square_sum) / 2

n = int(input())
A = list(map(int,input().split()))
 
print(int(int(findProductSum(A, n))%m))

Submission status: Wrong Answer

Solution code:
a = int(input())
p = list(map(int,input().split()))
t = 1
sum_list = []
for i in range(a):
    for t in range(a):
        if i >= t:
            continue
        w = p[i]*p[t]
        sum_list.append(w)

print(sum(sum_list))

Submission status: Wrong Answer

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

MOD = 10**9 + 7

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

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

# print(sum_A)
# print(sum_diag)

ans -= sum_diag
ans %= MOD
ans //= 2
ans %= MOD

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
B = list(combinations(A,2))
sum = 0
for i in range(len(B)):
    sum += B[i][0]*B[i][1]

print(sum%10000000007)

Submission status: Wrong Answer

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

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()
cnt = 0
s = 0
for j in a:
  s += j
  s = s%mod
for k in a:
    cnt += k**2%mod
    cnt = cnt%mod
ans = (((pow(s,2,mod)) - cnt)%mod)
print((ans//2)%mod)

Submission status: Wrong Answer

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

ans = (sum**2 - sum_re)/2

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

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

p = sum(A)

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

print(ans // 2)

Submission status: Wrong Answer

Solution code:
n = int( input() )

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

Sum = 0


for i in range(n):
	for j in range(i+1,n):
		Sum = Sum + i*j

print(Sum)

Submission status: Wrong Answer

Solution code:
# Date [ 2020-08-29 21:10:46 ]
# Problem [ c.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    a = read_int_list()
    
    ans = 0
    total = sum(a)
    for i in range(n):
        ans += (a[i] * (total - a[i])) % MOD
        ans %= MOD
    ans //= 2

    print(ans % MOD)            

if __name__ == '__main__':
    Main()

Submission status: Wrong Answer

Solution code:
import numpy as np


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

resolve()

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 += 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 
n = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 +7

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

# print(s%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 10**9+7
s = 0

for i in a:
    s += i
    s %= mod

s = (s * s) % mod
for i in a:
    s -= i*i
    s %= mod

s = s//2

print(s%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N = int(input())
A = input().split()

Sum = 0

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

ans = 0
for i in range(N):
    ans += (int(A[i])%1000000007*(Sum-int(A[i]))%1000000007)%1000000007

print(int(ans%1000000007/2))

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations

input = sys.stdin.readline

N = int(input())
A = list(map(int,input().split()))
B = list(combinations(A,2))
sum = 0
for i in range(len(B)):
    sum += B[i][0]*B[i][1]

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split(' ')))
mod = 10**9 + 7

sum_ = sum(a_list)
result = 0
for a in a_list:
  sum_ -= a
  result += ((sum_ % mod) * a) % mod

print(result)

Submission status: Wrong Answer

Solution code:
p=10**9+7
n=int(input())
A=[int(x) for x in input().split()]
A2=[(x**2) for x in A]
print(int((((sum(A))**2-sum(A2))/2)%p))

Submission status: Wrong Answer

Solution code:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    for j in range(i + 1, n):
        ans += curnum * arr[j]
        if ans >= 1000000007:
            ans -= 1000000007

if ans >= 1000000007:
    print(ans)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

MOD = 10**9+7

tot = sum(A)

ans = 0

for a in A:
    ans += a*(tot-a)
    ans %= MOD

ans //= 2
ans %= 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):
	for j in range(i,n):
		Sum = Sum + i*j

print(Sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

ans = 0
for i in range(N):
    pA = A[i] * A[i+1:]
    ans += pA.sum()

print(int(ans % (1e9+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 += 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 
n = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 +7

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

# print(s%MOD)

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	p = 1000000007
	S = 0
	Asq = 0
	for i in range(len(A)):
		x = A[i]
		S += x
		Asq += (x * x)
	t = (S * S) - Asq
	print(int(t / 2) % p)

main()

Submission status: Wrong Answer

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

wa = sum(A)
ans = 0
for i in range(n):
    ans += (wa - A[i]) * A[i]

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

Submission status: Wrong Answer

Solution code:
# C

N=int(input())
A=list(map(int,input().split()))
p=10**9+7

sumA = sum(A)

sumA2 = sum([a**2 for a in A])

print(int((sumA**2-sumA2)/2)%p)

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

sqsum = 0
asum = 0
for a in A:
  sqsum += a**2
  sqsum %= MOD
  asum += a
  asum %= MOD

ans = ((asum ** 2) - sqsum)
ans %= MOD

print(ans//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A.sort()
sam = 0
i = 0
while i < len(A):
  for a in A[i+1:]:
    if A[i] != a:
      sam += A[i] * a
  i += 1

print(sam%(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] )%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

n=int(input())
a=input().split()
for i in range(len(a)):
    a[i]=int(a[i])
ans=findProductSum(a,n)
ans=int(ans)

ans=ans%mod
print(ans)

Submission status: Wrong Answer

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

M = 0

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

Submission status: Wrong Answer

Solution code:
p=10**9+7
n=int(input())
A=[int(x) for x in input().split()]
A2=[(x**2) for x in A]
print((((sum(A))**2-sum(A2))/2)%p)

Submission status: Wrong Answer

Solution code:
int_n = int(input())
list_tmp = list(map(int, input().split()))

print(int_n, list_tmp)

int_sum = 0
int_divide = (10**9) + 7

for i in range(0, len(list_tmp) - 1):
  for j in range(i + 1, len(list_tmp)):
    #print(i, j)
    # print(list_tmp[i] * list_tmp[j])
    int_sum = ((int_sum + (list_tmp[i] * list_tmp[j])) % int_divide) #((list_tmp[i] * list_tmp[j]) )
#print(int_sum)
print(int_sum)

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
import heapq
import random
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv


def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]


class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h + 2) * (w + 2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid

    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x

    def getgrid(self, x, y):
        return self.grid[y][x]

    def get(self, x, y):
        return self.cost[self.pos(x, y)]

    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return

    def show(self):
        for i in range(self.h + 2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return

    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy


def solve(nums=0):
    n = getN()
    nums = getList()
    sumn = sum(nums)
    ans = 0
    for num in nums:
        ans += (num * (sumn - num)) % MOD
        ans %= MOD
    print(int(ans // 2))


def solve2(nums):
    n = len(nums)
    ans = 0
    for i in range(n):
        for j in range(i+1, n):
            ans += nums[i] * nums[j]

    return (ans % MOD)
if __name__ == "__main__":
    solve()
    # for i in range(100):
    #     nums = [random.randint(0, 100) for i in range(1000)]
    #     print(nums)
    #     # main()
    #     a1 = solve(nums)
    #     a2 = solve2(nums)
    #     if a1 != a2:
    #         print(nums)
    #         print(a1)
    #         print(a2)

Submission status: Wrong Answer

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

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (_*_)
sum1 = (sum1 * sum1)
print((sum1 - sum2)//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
# N = 2 * 10 ** 5
A = tuple(map(int, input().split()))
# A = [10 ** 9] * N
MOD = 10 ** 9 + 7
rev_sum_list = [0] * N
rev_sum_list[-1] = A[-1]
for i in range(N - 2, -1, -1):
    rev_sum_list[i] = (rev_sum_list[i + 1] + A[i]) % MOD
print(rev_sum_list)
ans = 0
for i in range(1, N):
    ans += A[i - 1] * rev_sum_list[i]
    ans %= MOD
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a=sum(A)%mod
a=(a**2)%mod
b=0
for i in range(n):
  b+=(A[i])**2
  b=b%mod
if a-b<0:
  c=a-b
  while c<=0:
    c+=mod
  
  ans=c//2
  ans=ans%mod

else:
  ans=(a-b)//2
  ans=ans%mod

print(ans)

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
A = readInts()
ans = ((sum(A))%mod)**2
ans %= mod
nya = 0
for i in range(n):
    nya += A[i] * A[i]
    nya %= mod
print(((ans - nya + mod))%mod//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = list(set(sorted(A)))
ans = 0
for i in range(len(A)-1):
    ans += (A[i] * sum(A[i+1::])) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % 10**9+7
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
MOD = 1000000007
n=int(input())
a=list(map(int,input().split()))
sum=0
for x,y in combinations(a,2):
   sum+= x*y%MOD
print(sum)

Submission status: Wrong Answer

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

sum1 = 0
sum2 = 0

for _ in a:
  sum1 += _
  sum2 += (_*_)
sum1 = (sum1 * sum1)
print(sum1 - sum2)

Submission status: Wrong Answer

Solution code:
n, *aa = map(int, open(0).read().split())
MOD = 10**9+7
print(((sum(aa)%MOD) ** 2 % MOD - sum(a**2%MOD for a in aa)%MOD)%MOD//2)

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br

sys.setrecursionlimit(100000000)

ii     =lambda: int(input())
si     =lambda: input()
jn     =lambda x,l: x.join(map(str,l))
sl     =lambda: list(map(str,input().strip()))
mi     =lambda: map(int,input().split())
mif    =lambda: map(float,input().split())
lii    =lambda: list(map(int,input().split()))

ceil   =lambda x: int(x) if(x==int(x)) else int(x)+1
ceildiv=lambda x,d: x//d if(x%d==0) else x//d+1

flush  =lambda: stdout.flush()
stdstr =lambda: stdin.readline()
stdint =lambda: int(stdin.readline())
stdpr  =lambda x: stdout.write(str(x))

mod=1000000007


#main code
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=ii()
arr=lii()
print(findProductSum(arr,n))