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:
#!/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
for k in a:
    cnt += k**2%mod
    cnt = cnt%mod
ans = (((sum(a)**2%mod) - cnt)%mod)
print((ans//2)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = input()
a = input()
al = a.split()
a_l = [int(n) for n in al]
pr = np.prod(a_l)
print(pr % (10**9 + 7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

S = sum(A)
ans = 0

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

print(ans//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
import itertools
aha=list(itertools.combinations(a,2))
kotae=0
for i in range(len(aha)):
    #print(aha[i])
    seki=aha[i][0]*aha[i][1]
    #print(seki)
    kotae+=seki
print(kotae)

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, n):
    b.append(a[i] * a[j])
print(sum(b))

Submission status: Wrong Answer

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

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

def main():
    a = cino()
    arr = cina()
    print(int(findProductSum(arr,a)))
        
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    total_sum = 0
    inv_cum_sum = []
    ans = 0 
    for i in range(len(A)):
        total_sum += A[i] % (1e9+7)
    tmp_cum_sum = 0
    for i in range(len(A)):
        tmp_cum_sum += A[i] % (1e9+7)
        inv_cum_sum.append(total_sum - tmp_cum_sum)
    for i in range(len(inv_cum_sum)):
        ans += (A[i] * inv_cum_sum[i]) % (1e9+7)
    print(int(ans % (1e9+7)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

suma = sum(a)%p
sumaa1 = (suma**2//2)%p

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

ans = (sumaa1-sumaa2)%p

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
(n,),a = [list(map(int, s.split())) for s in open(0)]
s2 = 0
mod = int(1e9+7)
for x in a:
    s2 += pow(x, 2, mod)
s = pow(sum(a), 1, mod)
ans = pow((s**2 - s2)//2, 1, mod)
print(ans)

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:
  ans=((a-b)+mod)//2
  ans=ans%mod

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

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)

Submission status: Wrong Answer

Solution code:
from numba import jit
@jit
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=10**9+7
  ans=0
  for i in range(n-1):
    ans=ans+(a[i]*(sum(a[i+1:n])%mod))%mod
  print(ans)
main()

Submission status: Wrong Answer

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

    ans = 0
    Asum = sum(A)
    for a in A:
        ans += a*(Asum-a)
        ans %=MOD
    print(ans//2)
main()

Submission status: Wrong Answer

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

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

x=0
for i in range(n):
    x+=a[i]*(A-a[i])
x=x%(10**9+7)
x=x//2
print(x)

Submission status: Wrong Answer

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

A_sum = sum(A)
B = [0]*N

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

ans = (A_sum**2 - sum(B))//2

print(ans)

Submission status: Wrong Answer

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

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

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

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

    # required sum is (array_sum_square -
    # individual_square_sum) / 2
    return ((array_sum_square - individual_square_sum) / 2)%mod
ans = int(findProductSum(a, n))
print(ans)

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

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

Submission status: Wrong Answer

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

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

print(sum)

Submission status: Wrong Answer

Solution code:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    n = int(input())
    As = list(map(int, input().split()))

    mod = 10**9+7
    _sum = 0
    for a in As:
        _sum += a
        _sum %= mod

    total = 0
    for a in As:
        total += a * (_sum - a)
        total %= mod

    total //= 2

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


sumA = sum(A)

sumAA = 0
for a in A:
    sumAA += a * a

X = int((sumA * sumA - sumAA) / 2) % 1000000007

print(X)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = list(map(int,input().split()))
sum = 0
mo = 1000000007
for i in range(n-1):
    for j in range(i+1,n):
        print(l[i]*l[j], sep = " ")
        sum += (l[i]*l[j])
        sum = sum%mo
print(sum)

Submission status: Wrong Answer

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

mod = 10**9 + 7

a_sum = sum(a_list)

ans = 0
for i in range(0, n):
    ans += (a_list[i] * (a_sum - a_list[i])) % mod
print(int((ans%mod)/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy
n = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 +7
x = numpy.array(a)
result = ((x.sum()**2 - x.dot(x)) / 2)%MOD
        
print(int(result))

Submission status: Wrong Answer

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

MOD = 1000000007

Alist = Alist[::-1]

mod = 0

ans = 0
for n in range(N-1):
    mod += (Alist[n]%MOD)
    mod = mod % MOD
    ans += (Alist[n+1] * mod)%MOD

print(ans)

Submission status: Wrong Answer

Solution code:
def main():

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

    mod = pow(10, 9) + 7
    v = 0
    u = 0
    for i in range(N):
        v += A[i]
        v %= mod
        u += A[i] * A[i]
        u %= mod
    k = (v * v - u) % mod
    return k // 2
    
if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
import numpy

N = int(input())
A = numpy.array([int(a) for a in input().split()])

ans = 0
for j in A:
    ans += j * numpy.sum(A[A < j])
    ans %= (10 ** 9 + 7)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

mod=1000000007
n = r()
a = rl()
b = [a[-1]]
for i in range(n-2,-1,-1):
    b.append(b[-1]+a[i])
b = b[::-1]
print(b)
ans = 0
for i in range(n-1):
    ans= (ans+(a[i]*b[i+1])%mod)%mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

point = 0
mod = 10**9+7

su_a = sum(a)%mod

for i in a:
    point += (su_a-i)*i
    point %= mod

point //= 2
point %= mod

print(point)

Submission status: Wrong Answer

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

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

mod = int(1e9+7)

S = sum(A) % mod

D = 0
for a in A:
  D += a**2
  D %= mod

ans = ((S**2 - D) % mod) // 2
print(ans)

Submission status: Wrong Answer

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

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

x=0
for i in range(n):
    x+=a[i]*(A-a[i])
x=x//2
x=x%(10**9+7)
print(x)

Submission status: Wrong Answer

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

a=(sum(A_ls))**2
for i in A_ls:
	a-=(i**2)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int( input() )

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

Sum = 0

for i in a:
	for j in a:
		Sum = Sum + i*j

print(Sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 10**9 + 7

ans = sum(A) * sum(A) % mod
ans += mod - (sum([a*a for a in A]) % mod)
ans %= mod
print(ans//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = 10**9+7
sum_a = sum(a)%mod
sum_a2 = sum_a**2%mod

for i in range(n):
    sum_a2 -= (a[i]**2)
    sum_a2 %= mod
    
ans = sum_a2//2

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()
cnt = 0
for k in a:
    cnt += k**2%mod
    cnt = cnt%mod
ans = ((((sum(a))**2%mod)-cnt)%mod)//2
if ans < 0:
  print(mod + ans)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
n = int(input())
#d, t, s = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

mod = 10 ** 9 + 7

sumlist= sum(a)
x = []
for i in range(n):
    x.append(sumlist - a[i])

ans = 0
for i in range(n):
    ans += (a[i] * x[i])
    ans %= mod

print(ans // 2)

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

ans = 0

for aa in a:
  ans += aa
  ans %= mod
ans *= ans
ans %= mod
for aa in a:
  ans -= aa*aa
  ans %= mod

ans //= 2
print(ans)

Submission status: Wrong Answer

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

S = [0]*N

for i in range(1,N):
    S[i] = (A[N-i]+S[i-1])%mod

print(S)
for j in range(1,N):
    ans += (S[j]*A[N-1-j])%mod
    ans = ans%mod

print(ans%mod)

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
s=sum(arr)
it=0
for item in arr:
    it+=item**2
print ((s**2-it)//2)

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(n):
    b.append((a[i] % (10 ** 9 + 7)) * (a[j] % (10 ** 9 + 7)))
print(sum(b))

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
print(int(((s**2-t)/2)%(10**9+7)))

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] * (AA - A[i])) % mod
print((ans % mod)//2)

Submission status: Wrong Answer

Solution code:
MOD = pow(10, 9) + 7

def main():
    N = int(input())
    A = list(map(int, input().split()))
    taikaku = 0
    for i in range(N):
        taikaku += pow(A[i], 2)
        taikaku %= MOD
    zennbu = 0
    sumA = sum(A)
    for i in range(N):
        zennbu += A[i]*sumA
        zennbu %= MOD
    ans = ((zennbu - taikaku) % MOD)//2
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
s=0
for i in range(0,n):
  x=l[i%n]*l[(i+1)%n]
  s=s+x
print(s)

Submission status: Wrong Answer

Solution code:
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
ilelec = lambda: map(int1,input().split())
alelec = lambda: list(map(int1, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

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  = alele()
print(int(findProductSum(A,N) % MOD))

Submission status: Wrong Answer

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

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

ans = ((sum_of_power - power_of_sum) / 2) % (1e9 + 7)

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ここまでテンプレ
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))

point = 0
mod = 10**9+7

su_a = sum(a)%mod

for i in a:
    point += (su_a-i)*i
    point %= mod

print(point//2)

Submission status: Wrong Answer

Solution code:
import numpy
n = int(input())
a = [int(x) for x in input().split()]
MOD = 10**9 +7
x = numpy.array(a)
result = ((x.sum()**2 - x.dot(x)) // 2)%MOD
        
print(result)

Submission status: Wrong Answer

Solution code:
import itertools
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    hoge = tuple(map(int, input().split()))
    sumn = 0
    for pair in list(itertools.combinations(hoge, 2)):
        sumn += (pair[0] * pair[1])
    print(sumn)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy

N = int(input())
A = numpy.array([int(a) for a in input().split()])

ans = 0
for j in A:
    ans += j * numpy.sum(A[A < j])

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

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a=(sum(A_ls))**2
for i in A_ls:
	a-=(i**2)

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

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

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)%p)//2)

Submission status: Wrong Answer

Solution code:
#Worst Solution
input()
l = list(map(int,input().split()))
r = 0
s = l
for i in range(len(l)):  
  for j in range(i+1,len(s)):
    r+=l[i]*l[j]
print(r)

Submission status: Wrong Answer

Solution code:
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    m = 10 ** 9 + 7
    s = sum(a) % m
    ans = 0
    for i in range(n):
        ans += (a[i] * (s - a[i]))
        ans %= m
    ans /= 2
    ans %= m
    print(ans)
    return



n = RN()
a = RA()
solve()

Submission status: Wrong Answer

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

MOD = 10**9 + 7

ans = 0
sum_arr = sum(arr)

for x in arr:
    ans += x * (sum_arr - x) // 2
    ans %= MOD

print(ans)

Submission status: Wrong Answer

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

for ai in A:
    ans+=(ai*(s-ai)/2)    
    if ans>=10**9+7:
        ans%=10**9+7
print(int(ans))

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]) % (10 ** 9 + 7)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 10 ** 9 +7
N = int(readline())
A = list(map(int,readline().split()))
total = sum(A)
B = [0] * N
for i in range(N):
    B[i] = (total-A[i]) % MOD
ans = 0 
for i in range(N):
    ans += A[i]*B[i]%MOD
    ans %=MOD
print(ans//2)

Submission status: Wrong Answer

Solution code:
def square(x):
  y = x**2
  return y


n = int(input())
al = list(map(int, input().split()))
als = list(map(square, al))

print(int((sum(al)**2-sum(als))/2)%(10**9+7))

Submission status: Wrong Answer

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

ans=sum(A)%(10**9+7)
ans=ans**2%(10**9+7)

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

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

Submission status: Wrong Answer

Solution code:
from itertools import *

n = int(input())
As = list(map(int, input().split()))
D = 10 ** 9 + 7
ans = 0
s = sum(As)

for a in As:
  ans = (ans + (s-a) * a) % D
  
print(ans // 2)

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:
M = 1e9 + 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 int(((array_sum_square - individual_square_sum) // 2)%M)

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

print(findProductSum(A,n))

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
print(((s**2 %P - s2)%P) // 2)

Submission status: Wrong Answer

Solution code:
import sys

MOD = 10**9 + 7

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

sumA = 0
for A in As:
    sumA += A
    sumA %= MOD
#print('# sumA:', sumA, file=sys.stderr)

ans = sumA * sumA % MOD
for A in As:
    ans -= A * A % MOD
    ans %= MOD
#print('# ans:', ans, file=sys.stderr)

ans //= 2
print(ans)

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] % (10**9+7)
  B += (A[i]**2) % (10**9+7)

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

Submission status: Wrong Answer

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

ans = 0
sum_a = sum(A)
for a in A:
  ans = (ans + (sum_a - a)*a)%mod

print(ans//2)

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7

total = sum( A )
ret = 0
for a in A:
  ret = ( ret + ( total - a ) * a  ) % mod
print( ret // 2 )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    mod = 10**9+7
    s = 0
    sq = 0
    for i in range(n):
        s += a[i]
        sq += (a[i])**2
        s %= mod
        sq %= mod
    s2 = (s**2) % mod

    ans = s2-sq
    if ans < 0:
        ans += mod
    print(ans//2)
resolve()

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] % (10**9+7)
  B += (A[i]**2) % (10**9+7)
  print(S,B)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
total = 0
for item in a:
    total = (total + item) % mod

total = (total * total) % mod

for item in a:
    total = (total - (item * item)) % mod

print(total // 2)

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
n = int(input())
#d, t, s = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))

mod = 10 ** 9 + 7

sumlist= sum(a)
x = []
for i in range(n):
    x.append(sumlist - a[i])

ans = 0
for i in range(n):
    ans += (a[i] * x[i] / 2)
    ans %= mod

print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

MOD = int(1e9) + 7

N = int(input())
A = list(map(int, input().split()))
S = sum(A) % MOD

ans = 0

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

print(ans // 2)

Submission status: Wrong Answer

Solution code:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]
 
def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))
 
def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))
 
def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD
 
    return (num*(pow(den,MOD-2,MOD)))%MOD
 
def flush():
    return sys.stdout.flush()




'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n = int(input())
a = arrIN()

pre = list(accumulate(a))

ans = 0
for i in range(n):
    ans+=(a[i]*pre[-1]-pre[i])
    ans%=MOD
print(ans)

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):
    other = wa-a[i]
    ans += other*a[i]
ans /= 2
print(int(ans%(1e9+7)))

Submission status: Wrong Answer

Solution code:
MOD = 10**9 + 7 
N = int(input())
A = [int(x) for x in input().split()]
S = sum(A)
ans = 0
for a in A:
    ans = (ans + a * (S-a)) % MOD
print(ans // 2)