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

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split()))) #[1,2,3]




print(alst)
s=np.cumsum(alst)
print(s)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=np.array(list(map(int,input().split()))) #[1,2,3]

s=np.cumsum(alst)

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i])

print(sum%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10**9 + 7

    As_cumsum = np.cumsum(As)
    ans = 0
    for i in range(1, n):
        ans += As[i] * As_cumsum[i-1]
        ans %= mod
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    mod = 10**9 + 7

    As_cumsum = np.cumsum(As)
    ans = 0
    for i in range(1, n):
        ans += As[i] * As_cumsum[i-1]
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
num = int(input())
str_in = input()
arr = [int(n) for n in str_in.split()]
mod = 1e9+7
s = []
he = 0
for i in range(0,num):
    temp = arr[i]
    he+=temp
    s.append(he)




he = 0
for i in range(0,num-1):
    temp = arr[i]*(s[num-1]-s[i])%mod
    he+=temp
    he=he%mod

print(int(he%mod))

Submission status: Wrong Answer

Solution code:
num = int(input())
str_in = input()
arr = [int(n) for n in str_in.split()]
mod = 1e9+7
s = []
he = 0
for i in range(0,num):
    temp = arr[i]
    he+=temp
    s.append(he)




he = 0
for i in range(0,num-1):
    temp = arr[i]*(s[num-1]-s[i])
    he+=temp

print(int(he%mod))

Submission status: Wrong Answer

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

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

print(ans // 2)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
array = np.array(list(map(int, input().split())))

total = 0
for i in range(N-1):
    total += sum(array[i] * array[i+1:])
print(total)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


# 整数の入力
n = int(input())
# スペース区切りの整数の入力
zzz = list(map(int, input().split()))
b=sum(zzz)**2
a=0
for i in range(n):
  # print(i)
  x=zzz[i]**2
  print(x)
  a +=x
# print(b)
# for a in zzz:
#   print(a)

# print(b)
# print(a)

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

Submission status: Wrong Answer

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

mod = 1000000007

ans = 0
tmp1, tmp2 = 0, 0

for m in A:
  tmp1 = (tmp1+m) %mod
  tmp2 = (tmp2+m*m%mod)%mod
  
ans = ((tmp1*tmp1)%mod-tmp2)%mod

if ans%2 ==0:
  ans = ans/2
else:
  ans =(ans+mod)/2

print(float(ans))

Submission status: Wrong Answer

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

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

print(int(ans % mod))

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):
    for j in range(n):
        if i >= j:
            continue
        print(i, j)
        ans += A[i] * A[j]

print(int(ans % mod))

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

print(ans)
print(int(ans % (10e9+7)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
  ak += A[i]
  ak_2 += A[i] ** 2
s = int(((ak ** 2) - ak_2) / 2)
print(s % mod)

Submission status: Wrong Answer

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

tot = 0
s_tot=0

for i in range(n):
    y=X[i]
    
    tot = (tot + y) %M
    #y_m= y ** 2 %M
    s_tot = s_tot + (y**2)
    #print(y,tot,s_tot)
ans = (tot**2 - s_tot)
if ans <0:
    ans+=M
ans = int(ans/2)
#ans = int( (tot**2 - s_tot) / 2) 
print(ans % M)
"""
if ans >= M:
    print(ans % M)
else:
    print((ans + M)% M)
"""

Submission status: Wrong Answer

Solution code:
import numpy as  np
mod = 1000000007
n = int(input())
a = list(map(int,input().split()))
ans = 0
s = np.zeros(n)
s[0] = a[0]
for i in range(1,n):
    s[i] = s[i-1]+a[i]

for i in range(n-1):
    ans += int((s[n-1]-s[i])*a[i]%mod)
    ans  = int(ans%mod)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as  np
mod = 1000000007
n = int(input())
a = list(map(int,input().split()))
ans = 0
s = np.zeros(n)
s[0] = a[0]
for i in range(1,n):
    s[i] = s[i-1]+a[i]

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

Submission status: Wrong Answer

Solution code:
import numpy as  np
mod = 1000000007
n = int(input())
a = list(map(int,input().split()))
ans = 0
s = np.zeros(n)
s[0] = a[0]
for i in range(1,n):
    s[i] = s[i-1]+a[i]

for i in range(n-1):
    ans += (s[n-1]-s[i])*a[i]
    ans  = int(ans%mod)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = sum(i for i in a)
ans = 0
base = 1e9 + 7
for i in a:
  res -= i
  ans += (i * res)
  
print(ans % base)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = np.zeros(N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = np.empty(N+1)  # 累積和テーブル B[i] = sum(A[:i])
mod = 10**9 + 7
ans = 0

for i in range(N):
    B[i+1] = B[i] + A[i]  # 累積和

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

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

diagSum = sum(list(map(lambda v: v ** 2, main)))

print(math.floor((sum(main) ** 2 - diagSum) / 2) % 1000000007)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

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

diagSum = sum(list(map(lambda v: v ** 2, main)))

print(math.floor((sum(main) ** 2 - diagSum) / 2) % 100000007)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

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

ans = 0

diagSum = sum(list(map(lambda v: v ** 2, main)))

print(math.floor((sum(main) ** 2 - diagSum)/2))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

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

ans = 0

diagSum = sum(list(map(lambda v: v ** 2, main)))

print(diagSum)

print(math.floor((sum(main) ** 2 - diagSum)/2))

Submission status: Wrong Answer

Solution code:
N = int(input())

ai_char = map(str, input().split(" "))
Ai = []
for i in ai_char:
    Ai.append(int(i))

print(Ai)

sum = 0
for i in range(N-1):
    for j in range(i+1, N):
        sum += Ai[i]*Ai[j]
        #print("{} {}".format(i, j))

print(sum%1000000007)

Submission status: Wrong Answer

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

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

sum = 0    
for i in range(0,N-1):
    sum += int(A[i]*S[i+1]%(1e9+7))

sum = int(sum%(1e9+7))    
print(sum)

Submission status: Wrong Answer

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

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

sum = 0    
for i in range(0,N-1):
    sum += A[i]*S[i+1]
    
sum = int(sum%(1e9+7))
print(sum)

Submission status: Wrong Answer

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

total = 0 

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

print(total)

Submission status: Wrong Answer

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

sum_A = sum(A)
A = np.array(A)

cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr



tot = 0
for i in range(N):
    tot += A[i] * (sum_A - int(cum_A[i]))
        
print(tot % 1000000007)

Submission status: Wrong Answer

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

sum_A = sum(A)

tot = 0
for i in range(N):
    sum_A -= A[i]
    tot += A[i] * sum_A
        
print(tot % 1000000007)

Submission status: Wrong Answer

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

A = np.array(A)
cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

sum_A = sum(A)

tot = 0
for i in range(N):
    tot += A[i] * (sum_A - A[i])
        
print(tot % 1000000007)

Submission status: Wrong Answer

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

A = np.array(A)
cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

sum_A = sum(A)

tot = 0
for i in range(N):
    tot += A[i] * (sum_A - cum_A[i])
        
print(tot % (1000000007))

Submission status: Wrong Answer

Solution code:
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

A = np.array(A)
cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

sum_A = sum(A)

tot = 0
for i in range(N):
    tot += A[i] * (sum_A - cum_A[i])
        
print(tot % (10 ** 9 + 7))

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-1):
  s-=a[i]
  ans+=a[i]*s
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
 
def square(x):
  return x * x
 
out = (square(sum(nums)) - sum(map(square, nums))) / 2
 
print(int(out % (10**9 + 7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(v) for v in input().split()]
MOD = int(1e9 + 7)

S = sum(A)
SQ = S * S
IS = sum(a*a for a in A)

print((SQ - IS) // 2)

Submission status: Wrong Answer

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

Sum = 0
Sum2 = 0
for i in range(N):
        Sum += A[i]
        Sum2 += A[i]*A[i]
        Sum %= MOD
        Sum2 %=MOD
        
ans = ((Sum*Sum)%MOD - Sum2 +MOD)%MOD
ans /= 2
print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
 
def square(x):
  return x * x
 
out = (square(sum(nums)) - sum(map(square, nums))) / 2
 
print(int(out % (1E9 + 7)))

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
 
def square(x):
  return x * x
 
out = (square(sum(nums)) - sum(map(square, nums))) / 2
 
print(int(out))

Submission status: Wrong Answer

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

Sum = 0
Sum2 = 0
for i in range(N):
        Sum += A[i]
        Sum2 += A[i]*A[i]
        Sum %= MOD
        Sum2 %=MOD
        
ans = (Sum*Sum - Sum2 +MOD)%MOD
ans /= 2
print(int(ans))

Submission status: Wrong Answer

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

sum_a = sum(A)
ans = 0

for i in range(n-1):
	sum_a -= A[i]
	ans += A[i] * sum_a 
	
print(int(ans %(1e9 + 7)))

Submission status: Wrong Answer

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

Sum = 0
Sum2 = 0
for i in range(N):
        Sum += A[i]
        Sum2 += A[i]*A[i]
        Sum %= MOD
        Sum2 %=MOD
        
ans = (Sum*Sum - Sum2)
ans /= 2
ans %= MOD

print(int(ans))

Submission status: Wrong Answer

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

Sum = 0
Sum2 = 0
for i in range(N):
        Sum += A[i]
        Sum2 += A[i]*A[i]
        Sum %= MOD
        Sum2 %=MOD
ans = (Sum*Sum - Sum2)%MOD
print(int(ans/2))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
mod = 1000000000 + 7
S = sum(A)
S2 = sum(map(lambda x: x*x,A))
#ans = (S*S - S2)// 2 % mod
ans = int((S*S - S2)/ 2 )% mod
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
mod = 1000000000 + 7
S = sum(A)
S2 = sum(map(lambda x: x*x,A))
ans = (int((S*S - S2)/2)%mod)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
mod = 1000000000 + 7
S = sum(A)
S2 = sum(map(lambda x: x*x%mod,A))
ans = ((S*S - S2)/2)%mod
print(int(ans))

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import numpy as np
n = int(input())
a = list(map(int, input().split()))
cum = np.cumsum(a)
# numpyで一次元リストの先頭に値を追加する時はnumpy.append()
cum = np.append(0, cum)
# print(cum)
ans = 0
mod = 10**9 + 7

for i in range(n):
    ans += a[i] * cum[i]
    # print(a[i], cum[i])

print(ans % mod)

Submission status: Wrong Answer

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

S = sum(A)
S2 = sum(map(lambda x: x*x,A))
ans = ((S*S - S2)/2)%1000000007
print(int(ans))

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import numpy
n = int(input())
a = list(map(int, input().split()))
cum = numpy.cumsum(a)
# print(cum)
ans = 0
mod = 10**9 + 7

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

Submission status: Wrong Answer

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

def solve(arr,n):
    M = (10**9)+7
    sums=sum(arr)

    ans=0
    for i in range(n):
        prod = (((sums-arr[i])%M)*arr[i]%M)%M
        ans = (ans%M+prod%M)%M

    return ans

print(solve(arr,n))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import accumulate

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

S = list(accumulate(A))

MOD = 1e+09 + 7

ans = 0

for i in range(1, len(A)):
    ans += ((A[i] % MOD) * (S[i-1] % MOD)) % MOD
    ans %= MOD

print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int,input().split()))
su=0
for i in arr:
  for j in arr:
    if(i<j):
      su = su + (i*j)
print(su%((10**9)+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=0
for i in a:
    ans+=i*(s-i)
    s=(s-i)
print(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]

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

Submission status: Wrong Answer

Solution code:
mod = pow(10, 9) + 7
n = int(input())
lt = [int(x) for x in input().split()]

sm =  0
for a in lt:
  sm = (sm + a)%mod 
  
sq = 0 
for a in lt:
  sq = (sq + pow(a, 2, mod))%mod 

ans = (pow(sm, 2, mod) - sq + mod)%mod 

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

Submission status: Wrong Answer

Solution code:
mod = pow(10, 9) + 7
n = int(input())
lt = [int(x) for x in input().split()]

sq = sum([x**2 for x in lt])
st = sum(lt)**2
ans = (st - sq + mod)%mod
ans = (ans//2)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
mod = pow(10, 9) + 7
n = int(input())

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

sq = sum([x**2 for x in lt])
st = sum(lt)**2
ans = (st - sq + mod)%mod
ans = (ans/2)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
#Ai*Ajの和を求めろ
s=sum(A)
ans=0
for i in range(N-1):
    s=s-A[i]
    ans+=A[i]*s
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
#Ai*Ajの和を求めろ
s=sum(A)
ans=0
for i in range(N-1):
    if i ==0:
        ans+=A[i]*(s-A[i])
    else:
        ans+=A[i]*(s-A[i]-A[i-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
#Ai*Ajの和を求めろ
s=sum(A)
ans=0
for i in A:
    s=s-i
    ans+=i*s
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
A = list(map(int, input().split()))
Com = itertools.combinations(A,2)
ans = 0

for C in Com:
    ans += (C[0]*C[1]) % (10**9+7)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
CONST = 10**9 + 7
n = int(input())
a = list(map(int,input().split()))
s = pow(sum(a),2,CONST)
for x in a:
    s -= pow(x,2,CONST)
    if s < 0: s += CONST
print(s//2)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
def main():
    n=int(input())
    a=list(map(int,input().split()))
    aa=list(accumulate(a))
    mod=10**9+7
    ans=0
    print(aa)
    for i in range(n):
        ans += a[i]*(aa[-1]-aa[i])%mod
    print(ans%mod)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    S = sum(A)
    ans = 0
    MOD = int(1e09 + 7)
    for i in range(N):
        ans += A[i] * (S - A[i])
        ans %= MOD
    ans //= 2
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in a:
  q = s-i
  ans += q
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [float(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0.0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int((sum_result/2.0) % target))

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [float(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0.0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int(sum_result/2) % target)

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int(sum_result/2) % target)

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int(sum_result/2) % target)

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num))
print(int(sum_result/2))

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list)

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num))
    if sum_result >= 10**9+7:
        sum_result = sum_result % target
print(int(sum_result/2))

Submission status: Wrong Answer

Solution code:
target = 10 ** 9 + 7

N = int(input())

# 全ての整数のリスト作成
int_list = list(input().split())
int_list = [int(n) for n in int_list]

int_sum = sum(int_list) % target

sum_result = 0
for num in int_list:
    sum_result += num * ((int_sum - num) % target)
    if sum_result >= 10**9+7:
        sum_result = sum_result % target
print(int(sum_result/2))

Submission status: Wrong Answer

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

mod= 10**9+7

A = sum(a)

ans=0

for i in a:
  ans += (A-i)*i %mod
print(ans//2%mod)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a2 = [i*i for i in a]
S = int((sum(a) * sum(a) - sum(a2))/2)
print(int(S % (1000000007)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    return ((array_sum_square - individual_square_sum) // 2) % tmp

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

print(float(findProductSum(a,n)))