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().strip().split()))[:n] 
def findProductSum(A,n): 
  
    product = 0
    for i in range (n): 
        for j in range ( i+1,n): 
            product = product + A[i]*A[j] 
    return product 
print(findProductSum(A,n))

Submission status: Wrong Answer

Solution code:
import numpy as np

n=int(input())
a_list=list(map(int,input().split()))
sum=0
ps=np.cumsum(a_list[::-1])[::-1] 
for i in range(n-1):
  sum+=a_list[i]*ps[i+1]

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

Submission status: Wrong Answer

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

MOD = 1000000007
ans = 0
powsum = 0
sumpow = 0
for i in range(N):
    powsum += A[i] 
    sumpow += (A[i]*A[i])

powsum = (powsum*powsum)
ans = ((powsum-sumpow)/2)
print(int(ans)%MOD)

Submission status: Wrong Answer

Solution code:
from decimal import *
mod = 10**9 + 7
N = int(input())
A = [Decimal(x) for x in input().split()]

s = Decimal(sum(A))
S = s**2
D = Decimal(sum([a**2 for a in A]))

print(int((S - D) / 2) % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)%(1000000007)
sumA2 = (sumA * sumA)%(1000000007)
square = 0
for i in range(N):
    square +=  ( A[i]**2 ) % (1000000007)
    square = square % (1000000007)
buf = sumA2 - square
if buf < 0:
  buf = buf + (1000000007)
res = ( buf * ((1000000007+1)/2)) % 1000000007
print(round(res))

Submission status: Wrong Answer

Solution code:
from decimal import *
mod = 10**9 + 7
N = int(input())
A = [int(x) for x in input().split()]

s = Decimal(sum(A))
S = s**2
D = Decimal(sum([a**2 for a in A]))

print(int((S - D) / 2) % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(x) for x in input().split()]
total = 0

for i in range(0,n-1):
    total += nums[i]*sum(nums[i+1:n])

print(total)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A, np.int64).cumsum()

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split(" ")))
 
    mod = 10**9+7
    res = 0

    for i in range(N-1):
        for j in range(i, N):
            if i >= j: break
            res += A[i] * A[j]
    print(res % mod)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
for i in range(N):
    sum = sum + (S[i+1]-A[i]) * A[i]
print(sum)

Submission status: Wrong Answer

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

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
    print(S[i+1])

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

print(sum)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A, np.int64).cumsum()

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

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n=int(input())
a_list=list(map(int,input().split()))
sum=0
ps=np.cumsum(a_list[::-1])[::-1] 
for i in range(n-1):
  sum+=a_list[i]*ps[i+1]

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A, dtype = np.int64).cumsum()

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

print(ans%mod)

Submission status: Wrong Answer

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

MOD = 1000000007
ans = 0
powsum = 0
sumpow = 0
for i in range(N):
    powsum += A[i]
    sumpow += (A[i]*A[i])

powsum = (powsum*powsum)
ans = ((powsum-sumpow)/2) %MOD
print(int(ans))

Submission status: Wrong Answer

Solution code:
MOD = 1e9 + 7

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

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

print((sum * sum - sum_diag) // 2 % MOD)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

while s >= 2*(10**9 +7):
  s = s % 2*(10**9 +7)
if s >= 10**9 + 7:
  s = s % (10**9)
s = s/2
 
print(int(s))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print(ans%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = list(map(int, input().split()))
 
size = len(ls)
 
ans = 0
for i in range(size - 1):
  gou = sum(ls[i+1:size])
  ans = ans + (gou * i)%1000000007
 
print(ans % 100000007)

Submission status: Wrong Answer

Solution code:
mod = 10**9 + 7
N = int(input())
A = [int(x) for x in input().split()]

s = sum(A)
S = s**2
d = sum([a**2 for a in A])

print(int(((S - d) % mod) / 2))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
Sum = 0
A = list(map(int, input().split()))
B = np.cumsum(np.array(A))
for i in range(N):
    Sum += A[i]*(B[-1]-B[i])
print(Sum%(1000000000+7))

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0]*(n+1)
    MOD = 10**9 + 7

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

Submission status: Wrong Answer

Solution code:
mod = 10**9 + 7
N = int(input())
A = [int(x) for x in input().split()]

s = sum(A)
S = s**2
d = sum([a**2 for a in A])

print(int((S - d) / 2) % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print(ans % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n = int(input())
item = [int(i) for i in input().split()]
mod = 10**9+7
t = (sum(item)**2 - sum([i**2 for i in item])) / 2
t = int(t)
print(t % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a_sum = sum(a)
aa = np.array(np.cumsum(a),dtype="int64")
all_a = sum(a)

mod = 1000000007

ans = 0
for i in range(n-1):
    ans += (a[i]%mod * (all_a - aa[i])%mod)

print(ans%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

N = int(input())
h = list(map(int, input().split()))
h2 = copy.copy(h)
ans = 0
s = np.sum(h2)
for i in range(N-1):
    s -= h[i]
    ans += h[i] * s
    ans = ans % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
Sum = 0
A = list(map(int, input().split()))
B = np.cumsum(np.array(A))
for i in range(N):
    Sum += A[i]*(B[N-1]-B[i])
print(Sum%(1000000000+7))

Submission status: Wrong Answer

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

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

x = round(k/2)
t = 10 ** 9 + 7
ans = x % t
print(ans)

Submission status: Wrong Answer

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

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

x = int(k/2)
t = 10 ** 9 + 7
ans = x % t
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
M = 1000000007
n = int(input())
A = list(map(int, input().split()))
ans = 0
s = 0
for i in range(n):
    s += A[i]
    s %= M

for i in range(n):
    s = s - A[i]
    if s < 0:
        s = M
    ans += (A[i] * s) % M
print(ans%M)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())), dtype = 'int64')
mod = 10**9 + 7

sq_sum_a = sum(a)**2
sum_sq_a = sum(a**2)

sum_cross = (sq_sum_a - sum_sq_a) // 2
ans = sum_cross % mod
# xy = ((x + y)**2 - (x**2 + y**2)) // 2

print(ans)

Submission status: Wrong Answer

Solution code:

n = int(input())
item = [int(i) for i in input().split()]
mod = 10**9+7
t = (sum(item)**2 - sum([i**2 for i in item]))

print(int(t * pow(2, -1, mod)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(e) for e in input().split()]
sum = 0
des = 0
for i in A :
    sum = sum + i
    des = des + i*i
sum = (sum*sum -des)/2
sum = sum%1000000007
print(int(sum))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print(ans % mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print(ans % mod)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
Sum = sum(A)
square_sum = sum(map(lambda x:x**2, A))
print((Sum**2 - square_sum)//2)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:

def readline():
	return map(int,input().split())
MOD=1e9+7
def solve():
	n=int(input())
	a=list(readline())
	ans=0;
	for i in range(n):
		ans+=a[i];
	ans=ans*ans
	for i in range(n):
		ans-=a[i]*a[i]
	ans=(ans//2)%MOD
	print(int(ans))
if __name__ == "__main__":
	#code goes below
	# for _ in range(int(input())):
		solve()

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
h = list(map(int, input().split()))
ans = 0
s = [h[N-1]]
for i in range(1, N):
    s.append(s[-1] + h[-i])
for i in range(N-1):
    ans += s[i-1]
ans = ans % (10 ** 9 + 7)
print(int(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
mod=1000000007
sum_a=sum(a)%mod

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
Sum = sum(A)
square_sum = sum(map(lambda x:x**2, A))
print((Sum - square_sum)//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(e) for e in input().split()]
sum = 0
asum = 0
for i in A :
    sum = sum + i
    asum = asum + i*i;
sum = ((sum*sum -asum)/2)%1000000007
print(int(sum))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(e) for e in input().split()]
sum = 0
asum = 0
for i in A :
    sum = i
    asum = i*i;
sum = ((sum*sum -asum)/2)%1000000007
print(int(sum))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print((ans+mod) % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
A_cum = np.array(A).cumsum()

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

print(ans % mod)

Submission status: Wrong Answer

Solution code:
n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod = 7+1000000000

amari = 0



for i in range(n):
    aa = 0
    for e in range(n-i-1):
        j = i+e+1
        if i != j:
            aa = aa + a[j]
    number = number + (a[i] * aa)
    if number >= mod:
        number = number - mod
print(number)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
input = stdin.readline
n = input().rstrip()
n = int(n)
a = list(map(int, input().split()))
a = np.array(a)
suma = np.cumsum(np.array(a))

ans = 0
for i in range(n-1):
    x = suma[n-1] - suma[i]
    x %= 1000000007
    ans += a[i] * x

ans %= 1000000007

print(ans)

Submission status: Wrong Answer

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

mod = (10**9 + 7)
ans = 0
s = sum(alist)

import numpy
alistsum = numpy.cumsum(alist)

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

ans = int(ans%mod)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a_sum = sum(a)
aa = np.array(a)
aaa = np.cumsum(aa)
aaa = aaa
all_a = sum(a)

ans = 0
for i in range(n-1):
    ans += (a[i]%(10**9+7) * (all_a - aaa[i]))

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
s=0
m=1e9+7
for i in A:
    s+=i
    s%=m
ans=0
for i in range(n-1):
    s-=A[i]
    if s<0:
        s+=m
    ans+=(A[i]%m)*s
    ans%=m
print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

mod = (10**9 + 7)
ans = 0
s = sum(alist)

import numpy
alistsum = numpy.cumsum(alist)

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

ans = ans%mod
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
 
partial_sum = A.copy()
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(1e9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%(1e9+7)) %(1e9+7)
print(int(res))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
a_sum = sum(a)
aa = np.array(a)
aaa = np.cumsum(aa)
aaa = aaa
all_a = sum(a)

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = [0]
ans = 0
for i in range(0, n, 1):
    s.append((s[i] + a[i]) % 1000000007)

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

print(ans)

Submission status: Wrong Answer

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

MOD = 1000000007

def mod(n):         
  return n % MOD

def multiply(a, b): #mod(a*b)を求める
  return mod(mod(a)*mod(b))

ans = mod(multiply(mod(sum(lst)), mod(sum(lst))))

for i in range(n):
  ans -= multiply(lst[i], lst[i])
  
ans = mod(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod0 = 1000000000
mod1 = 7

amari = 0



for i in range(n):
    aa = 0
    for e in range(n-i-1):
        j = i+e+1
        if i != j:
            aa = aa + a[j]
    number = number + (a[i] * aa)
amari0 = number % mod0
amari1 = number % mod1
amari = amari0 + amari1
print(amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
print(a2)
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


ans = 0
B = [0] * (N + 1)

for i in range(N-1, -1, -1):
    print(i)
    B[i] = (B[i+1] + A[i]) % D

for i in range(0, N-1):
    ans += (A[i] * B[i+1]) % D

print(int(ans % D))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

mod = (10**9 + 7)
ans = 0

import numpy
alistsum = numpy.cumsum(alist)

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

ans = ans%mod
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import accumulate


def main():
    n = int(input())
    array = [int(x) for x in input().split()]
    mod = 10 ** 9 + 7
    total = 0
    center_blocks = 0
    for x in array:
        total += x
        total %= mod
        center_blocks += x ** 2
        center_blocks %= mod
    total = total ** 2 % mod
    return (total - center_blocks) // 2 % mod


if __name__ == '__main__':
    print(main())

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))
dot2=int(dot/2)
print(dot2%(1000000007))

Submission status: Wrong Answer

Solution code:
MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))
a_sum=sum(A)%MOD
ans=(a_sum**2)%MOD
ans-=sum(map(lambda x: x*x%MOD, A))%MOD
print(ans//2%MOD)

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))
dot2=dot/2
print(int(dot2%(1000000007)))

Submission status: Wrong Answer

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

mod=10**9+7
total = sum(a)
cum=[]

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

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))
s = 0
for i in range(0,N):
  s += a[i]

s = s*s

for i in range(0,N):
  s -= a[i]*a[i]

while s >= 2*(10**9 +7):
  s = s % (10**9 +7)
if s >= 10**9 + 7:
  s = s % (10**9)
s = s/2
 
print(int(s))

Submission status: Wrong Answer

Solution code:

n = int(input())
item = [int(i) for i in input().split()]
mod = 10**9+7
ans = (sum(item)**2 - sum([i**2 for i in item])) / 2

print(int(ans % mod))

Submission status: Wrong Answer

Solution code:
from itertools import accumulate
mod= 1e9+7

def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))

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

if __name__ == '__main__':
    main()

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
s = sum(a)
for k in a:
    cnt += k**2
    cnt = cnt
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 = 0
for i in range(n):
    sum += a[i]
sum = sum*sum
for j in range(n):
    sum = sum - a[j]*a[j]
sum = int(sum/2)
print(sum%1000000007)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
x=sum(a)
y=sum(a[i]**2 for i in range(n))
z=(x*x-y)/2

print(int(z%1000000007))

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = [int(x) for x in input().split()]
lists2 = lists
sum = 0

for x in lists:
    for y in lists2:
        if x <= y :
            continue
        else:
            product = x * y
            sum += product

k = 10**9 + 7
t = sum % k
print(t)

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

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

Submission status: Wrong Answer

Solution code:
n,*l=map(int,open(0).read().split())

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
x=sum(a)
y=sum(a[i]**2 for i in range(n))
z=(x*x-y)/2

print(z%1000000007)

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

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

Submission status: Wrong Answer

Solution code:

import copy

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

partial_sum = copy.deepcopy(A)
sum_now = A[N-1]
for j in range(N-2,-1,-1):
    sum_now = int((sum_now+A[j])%(1e9+7))
    partial_sum[j] = sum_now
res = 0
for i in range(N-1):
    res = (res + (A[i]*partial_sum[i+1])%(1e9+7)) %(1e9+7)
print(int(res))

Submission status: Wrong Answer

Solution code:
MODINT = 1000000007
n = int(input())
A = list(map(int,input().split()))
prodsum = [0]*n
prodsum[0] = A[0]
for i in range(1,n):
    prodsum[i] = prodsum[i-1]+A[i]
# print(prodsum)
ans = 0
for i in range(n-1):
    ans += A[i]*(prodsum[-1]-prodsum[i])
    ans % MODINT
print(ans)

Submission status: Wrong Answer

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

S = sum(A)
S2 = sum(map(lambda x:x*x, A))

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