Problem: 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).

Submission attempts (in order):
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)

import numpy as np

MOD = 10 ** 9 + 7

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

s=list(np.cumsum(alst))
s.insert(0,0)
print(s)

sum=0

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

print(sum%MOD)

import numpy as np

MOD = 10 ** 9 + 7

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





# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='list')

sum=0

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

print(sum%MOD)

MOD = 10 ** 9 + 7

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





# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]

s=[0]
for i in range(len(alst)):
  s.append(s[i]+alst[i])

print(s)
sum=0

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

print(sum%MOD)

import numpy as np

MOD = 10 ** 9 + 7

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





# [0,1,3,6,10,15,21]

s=np.cumsum(alst)
ans=[0]

for i in range(len(s)):
  ans.append(s[i])

sum=0

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

print(sum%MOD)

import numpy as np

MOD = 10 ** 9 + 7

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





# [0,1,3,6,10,15,21]

s=np.cumsum(alst,dtype='float32')

sum=0

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

print(sum%MOD)

import numpy as np

MOD = 10 ** 9 + 7

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


s=np.cumsum(alst)

sum=0

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

print(sum%MOD)

import numpy as np
MOD = 10 ** 9 + 7

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





# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]

s=[0]
for i in range(len(alst)):
  s.append(s[i]+alst[i])

print(s)
sum=0

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

print(sum%MOD)

import numpy as np

MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split()))


s=np.cumsum(alst)

sum=0

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

print(sum%MOD)

import numpy as np

MOD = 10 ** 9 + 7

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





# [0,1,3,6,10,15,21]

s=np.cumsum(alst)
ans=[0]

for i in range(len(s)):
  ans.append(s[i])

print(ans)
sum=0

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

print(sum%MOD)

MOD = 10 ** 9 + 7


# [0,1,3,6,10,15,21]
cumsum=[0]
def my_cumsum(alst):
  for i in range(len(alst)):
    cumsum.append(cumsum[i]+alst[i])
  return cumsum

n=int(input()) #3
alst=list(map(int,input().split()))


# s=np.cumsum(alst)

s=my_cumsum(alst)

sum=0

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

print(sum%MOD)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted