ZhenlongDai/ACPR huggingface dataset:
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7
sum_A = sum(A)
ans = 0
for i in range(n-1):
    sum_A -= A[i]
    ans += (A[i]*sum_A)%MOD
print(ans)


Failing test case input:
4
12645692 101747 435150 75715

Expected output:
828976092


Actual output:
2828976106


Fixed submission (verdict: Accepted):
MOD=10**9+7
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)%MOD
print(ans%MOD)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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)

Failing test case input:
4
3646424 4102 178 11813

Expected output:
733190822


Actual output:
[3662517, 16093, 11991, 11813]
733190822


Fixed submission (verdict: Accepted):
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]
ans = 0
for i in range(n-1):
    ans= (ans+(a[i]*b[i+1])%mod)%mod
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
 
a=list(map(int,input().split()))
num=0
for i in a:
  for j in a[n:i-1:-1]:
    num=num+(i*j)
else:
  print(num % 1000000007)
    

Failing test case input:
4
27651699 119786 2501999 72528

Expected output:
188837537


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())

l = 1000000007
a=list(map(int,input().split()))
s = sum(a)
num = 0
for i in range(n):
  s = s- a[i]
  num =num+a[i]*s
else:
  print(num%l)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

M = 10**9 + 7

Total = sum(A) -A[0]

ans = 0

for i in range(N-1):
    ans += A[i] * Total
    ans % M
    Total -= A[i+1]

print(ans)

Failing test case input:
4
3855157 98660 9743 12204

Expected output:
243111622


Actual output:
467243114891


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

M = 10**9 + 7

Total = sum(A) -A[0]

ans = 0

for i in range(N-1):
    ans += A[i] * Total
    ans = ans % M
    Total -= A[i+1]

print(ans)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
t=0
for i in range(n):
    t=(t+a[i])%mod
s=t*t%mod
m=0
for i in range(n):
    m+=a[i]**2%mod
ans=((s-m)%mod)
print(ans)

Failing test case input:
4
3646424 64145 182 6247

Expected output:
756250736


Actual output:
512501465


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
t=0
for i in range(n):
    t=(t+a[i])%mod
s=t*t%mod
m=0
for i in range(n):
    m=(m+(a[i]**2)%mod)%mod
d=pow(2,mod-2,mod)
ans=((s-m)%mod)*d
print(ans%mod)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
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)

Failing test case input:
4
28568719 139427 593808 94229

Expected output:
471200910


Actual output:
471200910.0


Fixed submission (verdict: Accepted):
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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
SUM = 0
for i in range(N-1):
    j=i+1
    for j in range(N):
        SUM += A[i] * A[j] % MOD
print(SUM)

Failing test case input:
4
3195143 101747 435150 75715

Expected output:
309292627


Actual output:
5693870765


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
S = sum(A) % MOD
ans = 0

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)


Failing test case input:
4
3646424 64145 903 6247

Expected output:
436075051


Actual output:
2.2970353447958898


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
if sum(a)==0:
    print(0)
    exit()
else:
    k=0
    s=sum(a)
    for i in range(n-1):
        s-=a[i]
        s1=s%(10**9+7)
        k+=(s1*a[i])%(10**9+7)
print(k%(10**9+7))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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(findProductSum(a,n))


Failing test case input:
4
1069110 84292 143968 6344

Expected output:
400912688


Actual output:
400912688.0


Fixed submission (verdict: Accepted):
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) 

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

print(findProductSum(a,n))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a=int(input())
b = list(map(int, input().split()))
b.sort()
S=0
c=sum(b)
for i in range(0,a):
    S=S+b[i]*(c-b[i])
print(S % (10**9+7))


Failing test case input:
4
8519677 3228 189 33

Expected output:
393608300


Actual output:
787216600


Fixed submission (verdict: Accepted):
a=int(input())
b = list(map(int, input().split()))
b.sort()
S=0
c=sum(b)
for i in range(0,a):
    c=c-b[i]
    S=S+b[i]*c
print(S % (10**9+7))

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
m = 10**9 + 7
n = input()
a = list(map(int,input().split()))
ans = 0
s = sum(a)

for i in a:
  s -= i
  ans += s*i
  s += i

ans = ans%m

print(ans)

Failing test case input:
4
3646424 4102 178 11813

Expected output:
733190822


Actual output:
466381637


Fixed submission (verdict: Accepted):
m = 10**9 + 7
n = input()
a = list(map(int,input().split()))
ans = 0
s = sum(a)

for i in a:
  s -= i
  ans += s*i

ans = ans%m

print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
line = list(map(int, input().split()))
a = 10**9 +7
total = sum(line)%a
output = total**2 %a
for i in range(N):
    output = (output - (line[i]**2)%a)%a
print(int(output/2))
    

Failing test case input:
4
1837207 84292 9743 6344

Expected output:
834815154


Actual output:
334815150


Fixed submission (verdict: Accepted):
N = int(input())
line = list(map(int, input().split()))
a = 2*(10**9 +7)
total = sum(line)%a
output = total**2 %a
for i in range(N):
    output = (output - (line[i]**2)%a)%a
print( int(output/2))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))


Failing test case input:
4
6290673 230 6 33

Expected output:
692200198


Actual output:
192200194


Fixed submission (verdict: Accepted):
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:
    int_sum -= num
    sum_result += num * int_sum
print(sum_result % target)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from itertools import combinations
import math
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(add(result[-1], x))
    return result








inv = cumsum(list(reversed(A)))
c = 0
for i in range(0,N-1):
    print(N-i-2)
    c = add(c,mul(A[i],inv[N-i-2]))

print(c)


Failing test case input:
4
6290673 230 6 33

Expected output:
692200198


Actual output:
2
1
0
692200198


Fixed submission (verdict: Accepted):
from itertools import combinations
import math
N = int(input())
A = list(map(int, input().split()))
mod = 1000000007

def add(a, b):
    return (a + b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def cumsum(xs):
    result = [xs[0]]
    for x in xs[1:]:
        result.append(add(result[-1], x))
    return result








inv = cumsum(list(reversed(A)))
c = 0
for i in range(0,N-1):
    c = add(c,mul(A[i],inv[N-i-2]))

print(c)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

sum_of_product = (sum(A) ** 2)

for i in A:
    sum_of_product -= i ** 2

sum_of_product %= 10 ** 9 + 7

print(sum_of_product)

Failing test case input:
4
4932847 3416 189 33

Expected output:
946461856


Actual output:
892923705


Fixed submission (verdict: Accepted):
input()
A = list(map(int, input().split()))

sum_list = sum(A)
sum_of_product = 0

for i in A:
    sum_list -= i
    sum_of_product = ((sum_list * i) % (10 ** 9 + 7) + sum_of_product) % (10 ** 9 + 7)

print(sum_of_product)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

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


Failing test case input:
4
141421356 15438004 10545868 176612

Expected output:
309796111


Actual output:
3867047367801818694923520


Fixed submission (verdict: Accepted):

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)) % mod)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)


Failing test case input:
4
6160134 101747 143968 75715

Expected output:
304480850


Actual output:
1304480857


Fixed submission (verdict: Accepted):
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%mod)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
from collections import defaultdict

input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

D = defaultdict(int)
ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        v = A[i] * A[j] % MOD
        D[v] += 1
print(D)


Failing test case input:
4
28568719 139427 593808 94229

Expected output:
471200910


Actual output:
defaultdict(<class 'int'>, {250756132: 1, 333773204: 1, 1803807: 1, 792867442: 1, 138066692: 1, 953933647: 1})


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.buffer.readline
MOD = 10**9 + 7

N = int(input())
A = [0] + list(map(int, input().split()))

C = [0]
for i in range(1, len(A)):
    C.append(C[-1] + A[i])

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

ans %= MOD
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import copy
mod=10**9+7
def calc(nums,n):
    if n==1:
        return 0
    if n==2:
        return nums[0]*nums[1]
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save+nums[i+1])%mod
        save=s
    ans=0  
    print(nums)
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
       





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))


Failing test case input:
4
4932847 3228 189 33

Expected output:
19044884


Actual output:
[3450, 222, 33, 33]
19044884


Fixed submission (verdict: Accepted):
import copy
mod=10**9+7
def calc(nums,n):
    if n==2:
        return ((nums[0]%mod)*(nums[1]%mod))%mod
    cpy=copy.deepcopy(nums)    
    save=nums[n-2]
    nums[n-2]=nums[n-1]
    for i in range(n-3,-1,-1):
        s=nums[i]%mod
        nums[i]=(save%mod+nums[i+1]%mod)%mod
        save=s%mod
       
    ans=0  
    
    for i in range(n-1):
        ans=((ans%mod)  +  ((cpy[i]%mod)*(nums[i]%mod))%mod)%mod
    return ans       
    





n=int(input())
nums=list(map(int,input().split()))
print(calc(nums,n))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
ans = 0
mod = 1e9 + 7
s = sum(A) % mod

for i in range(N):
    s -= A[i]
    ans += (A[i] * s) % mod
    ans = ans % mod
print(ans)

Failing test case input:
4
1988253 116846 9743 6344

Expected output:
245945381


Actual output:
245945381.0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

ans = 0
mod = int(1e9 + 7)
s = sum(A) % mod

for a in A:
    s -= a
    ans += (a * s) % mod
    ans %= mod

print(int(ans))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
s = 0
ans = 0
for i in range(len(a)):
  s += a[i]
for i in range(len(a)-1):
  s -= a[i]
  ans += s*a[i]
print(int(ans%1e9+7))

Failing test case input:
4
14846625 119786 2501999 47420

Expected output:
714899675


Actual output:
715180046


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
s = 0
ans = 0
for i in range(len(a)):
  s += a[i]
for i in range(len(a)-1):
  s -= a[i]
  ans += s*a[i]
  ans %= 1000000007
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
numbers = list(map(int, input().split()))
numbers = [i % 1000000007 for i in numbers]

sum = 0
for i in range(n):
    for j in range(i + 1, n):
        sum += (numbers[i] * numbers[j]) % 1000000007
print(sum)

Failing test case input:
4
27651699 211119 10406344 72528

Expected output:
451650168


Actual output:
3451650189


Fixed submission (verdict: Accepted):
n = int(input())
numbers = list(map(int, input().split()))
result = 0
sum_of_numbers = sum(numbers)
for i in range(n - 1):
    sum_of_numbers -= numbers[i]
    result += numbers[i] * sum_of_numbers
    result %= 1000000007
print(result)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = input().split(' ')
a = 0
sum = 0
for i in range(1, N):
    sum += int(A[i])
for i in range(N):
    a += int(A[i]) *  sum
    if i < N - 1:
        sum -= int(A[i + 1])
    a %= (10e9 + 7)
    
    
print(int(a))

Failing test case input:
4
141421356 5143928 4405286 176612

Expected output:
471127930


Actual output:
6479946586


Fixed submission (verdict: Accepted):
N = int(input())
A = input().split(' ')
a = 0
sum = 0
for i in range(1, N):
    sum += int(A[i])
for i in range(N):
    a += int(A[i]) *  sum
    if i < N - 1:
        sum -= int(A[i + 1])
    
print(int(a % (10 ** 9 + 7)))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
x = list(map(int, input().split()))
s = 0

for i in range(N-1):
  for j in range(i+1,N):
    s = s + x[i]*x[j] % 1000000007

print(s)


Failing test case input:
4
1988253 116846 9743 6344

Expected output:
245945381


Actual output:
2245945395


Fixed submission (verdict: Accepted):
N = int(input())
x = list(map(int, input().split()))
s = sum(x) - x[0]
ans = 0

for i in range(N-1):
  ans = ans + x[i]*s
  s = s - x[i+1]
ans = ans % 1000000007
  
  
print(ans)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A=list(map(int, input().split()))
B=[A[N-1]]

for i in range(len(A)-2):
    
    b=B[i]+A[N-2-i]
    B.append(b)
print(B)
total=0
for i in range(len(B)):
    total += A[i]*B[len(B)-1-i]

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

Failing test case input:
4
2519048 3416 189 985

Expected output:
566626792


Actual output:
[985, 1174, 4590]
566626792


Fixed submission (verdict: Accepted):
N = int(input())
A=list(map(int, input().split()))
B=[A[N-1]]

for i in range(len(A)-2):
    
    b=B[i]+A[N-2-i]
    B.append(b)

total=0
for i in range(len(B)):
    total += A[i]*B[len(B)-1-i]

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]

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


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

Failing test case input:
4
141421356 17320508 22360679 244949

Expected output:
437235829

Actual output:
1437235836


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]
m = 1000000007
ans = 0

b = [0]
for i in range(1,n+1):
  b.append((a[i-1] + b[i-1]) % m)

           
for i in range(n):
	p = b[n] - b[i+1]
	p *= a[i]
	p = p % m
	ans += p
	ans = ans % m
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())

s = input().split(" ")

ans = 0
for i in range(n):
  for j in range(int(i)+1,n-1):
    
    ans += int(s[i])*int(s[j])
print(ans%(10**9+7))

Failing test case input:
4
4602446 4102 176 11813

Expected output:
109216034


Actual output:
689985807


Fixed submission (verdict: Accepted):
n = int(input())

s = input().split(" ")

sumup = 0
for i in s:
  sumup += int(i) 

ans = 0
for i in s:
  r = int(i)
  
  sumup -= r
  
  ans += r*sumup
    
print(ans%(10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
num = int(input(""))
val = list(map(int,input().split()))
val_sum = 0
mod = 10**9 + 7

for i in range(num):
    for j in range(i+1,num):
        val_sum = val_sum + ((val[i]*val[j])%mod)
        
print(val_sum)

Failing test case input:
4
1837207 116846 9743 6344

Expected output:
166947603


Actual output:
3166947624


Fixed submission (verdict: Accepted):
num = int(input(""))
val = list(map(int,input().split()))
val_sum = sum(val)
ans = 0
mod = 10**9 + 7

for i in range(num):
    val_sum = val_sum - val[i]
    ans     = val[i] * val_sum + ans
        
print(ans%mod)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7

    tmp = [0] * N

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

    print(tmp)

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

    print(ans % mod)


if __name__ == '__main__':
    main()


Failing test case input:
4
2509638 64145 903 5951

Expected output:
626810699


Actual output:
[70999, 6854, 5951, 0]
626810699


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    mod = 10**9 + 7

    tmp = [0] * N

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

    

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

    print(ans % mod)


if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(float, input().rstrip().split()))
ans = 0
add = 0

for i in range(N):
	add += As[i]
	add %= mod
ans = add * add % mod

for i in range(N):
	ans -= As[i] * As[i] % mod
	if (ans < 0):
		ans += mod

ans *= (mod + 1) / 2

print(ans % mod)

Failing test case input:
4
27651699 211119 5914431 72528

Expected output:
308671651


Actual output:
308671627.0


Fixed submission (verdict: Accepted):

mod = 10 ** 9 + 7


N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))
ans = 0
add = 0

for i in range(N):
	add += As[i]
	add %= mod
ans = add * add % mod

for i in range(N):
	ans -= As[i] * As[i] % mod
	if (ans < 0):
		ans += mod

ans *= int((mod + 1) / 2)
ans %= mod

print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]
    sum%=mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
    sum_1%=mod

ans = (sum - sum_1)/2
ans = ans%mod

print(int(ans))


Failing test case input:
4
4932847 3228 189 33

Expected output:
19044884


Actual output:
519044887


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]%mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += (A[j]**2)%mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2*500000004)%mod
print(int(ans))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4
141421356 2224125 5164610 29158

Expected output:
658249038


Actual output:
3
2
1
0
658249038


Fixed submission (verdict: Accepted):
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):
    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))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    mod = 1000000007
    
    n = int(input())
    a = [int() for x in input().split()]
    ans = 0
    asum = sum(a)
    for i in range(n):
        asum = asum - a[i]
        ans += (a[i] * asum) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()

Failing test case input:
4
8519677 3228 189 33

Expected output:
393608300


Actual output:
0


Fixed submission (verdict: Accepted):
def main():
    mod = 10**9+7
    
    n = int(input())
    a = [int(x) for x in input().split()]
    ans = 0
    asum = sum(a) 
    for i in range(n):
        asum = asum - a[i]
        ans = ( ans + ((a[i] * asum) % mod)) % mod
    
    print(ans)
    
if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]
    sum%=mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += A[j]**2
    sum_1%=mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2/2)%mod
print(int(ans))


Failing test case input:
4
1837207 84292 9743 6344

Expected output:
834815154


Actual output:
334815150


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
sum = 0
sum_1 = 0

for i in range(N):
    sum += A[i]%mod
sum = (sum**2)%mod

for j in range(N):
    sum_1 += (A[j]**2)%mod
sum2=sum-sum_1
if sum2<0:
    sum2+=mod
ans=(sum2*500000004)%mod
print(int(ans))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]
a_sum = sum(a_list)

total = 0
for i in range(0, len(a_list)-1):
    total += a_list[i] * (a_sum - a_list[i])
total = total % max
print(total)


Failing test case input:
4
2519048 3927 176 1307

Expected output:
634103362


Actual output:
970448388


Fixed submission (verdict: Accepted):
n = input()
 
max = 10**9 + 7
 
a_list = [int(a) % max for a in input().split(" ")]
a_sum = sum(a_list)

total = 0
for i in range(0, len(a_list)-1):
    a_sum -= a_list[i]
    total += a_list[i] * a_sum
total = total % max
print(total)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
 
A = list(map(int, input().split()))
 
c = 0
 
for i in range(N-2):
  for j in range(int(i)+1, N):
    d = A[i] 
    e = A[j] 
    c = (c + d*e) % (10**9+7)
    
    
 
c = c % (10**9+7)
 
print(c)

Failing test case input:
4
141421356 2224125 5164610 29158

Expected output:
658249038


Actual output:
68551708


Fixed submission (verdict: Accepted):
N = int(input())

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

S = 0
for i in range(N):
  S += A[i]

c = S
d = 0
for j in range(N):
  c -= A[j]
  c = c%(10**9+7)
  d += A[j]*c
  d = d%(10**9+7)
  
print(d)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
tmp = sum(A)

print(sum(a * (tmp - a) for a in A))


Failing test case input:
4
2509638 64145 5782 11005

Expected output:
250454213


Actual output:
408500911282


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
tmp = sum(A)
sum_ = 0

for a in A:
    tmp -= a
    sum_ += a * tmp

print(sum_ % (1_000_000_007))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=0
suma=sum(a)
for i in range(n):
  ans+=(a[i]*(suma-a[i])%(10**9+7))
print(int((ans)%(10**9+7)/2))

Failing test case input:
4
141421356 22198551 4405286 176612

Expected output:
907440962


Actual output:
407440958


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=0
suma=sum(a)
for i in range(n):
  suma-=a[i]
  ans+=(a[i]*(suma))%(10**9+7)
print(int(ans%(10**9+7)))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

sum_of_product = sum(A) ** 2

for i in A:
    sum_of_product -= i ** 2

sum_of_product = (sum_of_product / 2) % (10 ** 9 + 7)

print(sum_of_product)

Failing test case input:
4
5548583 84292 143968 75715

Expected output:
48561969


Actual output:
48561969.0


Fixed submission (verdict: Accepted):
input()
A = list(map(int, input().split()))

sum_list = sum(A)
sum_of_product = 0

for i in A:
    sum_list -= i
    sum_of_product = ((sum_list * i) % (10 ** 9 + 7) + sum_of_product) % (10 ** 9 + 7)

print(sum_of_product)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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) 
print(ans)

Failing test case input:
4
141421356 1512598 4405286 176612

Expected output:
478491412


Actual output:
956982824


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

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

mod = int(1e9+7)

S = sum(A)

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

print(ans)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
 
s = 0
for i in range(N):
  s += A[i]
  s %= (10**9+7)
s = s**2
s %= (10**9+7)
 
t = 0
for i in range(N):
  t += (A[i]**2 % (10**9+7))
t %= (10**9+7)
 
ans = (s-t) % (10**9+7)
print(int(ans/2))

Failing test case input:
4
28568719 211119 10406344 94229

Expected output:
766457999


Actual output:
266457995


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
 
s = 0
for i in range(N):
  s += A[i]
  s %= (10**9+7)
s = s**2
s %= (10**9+7)
 
t = 0
for i in range(N):
  t += (A[i]**2 % (10**9+7))
t %= (10**9+7)
 
ans = (s-t) % (10**9+7)

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
MOD = 1e9 + 7
N = int(input())
A = list(map(int, input().split()))
c = 0
S = sum(A)
for i in range(N):
    c += (A[i] % MOD) * ((S - A[i]) % MOD)
    c %= MOD
mod = pow(2, -1, 1000000007)
c = c * mod
c %= MOD
print(int(c))

Failing test case input:
4
6341164 105854 435150 70292

Expected output:
418782092


Actual output:
418782124


Fixed submission (verdict: Accepted):
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
c = 0
S = 0
for a in A:
  S += a % MOD
  S %= MOD
for i in range(N):
    c += (A[i] % MOD) * ((S - A[i] % MOD) % MOD)
    c %= MOD
mod = pow(2, -1, 1000000007)
c = c * mod
c %= MOD
print(int(c))

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
prod_sum = 0
sum_arr = [0]*n
sum_arr[n-1] = a[n-1]
for i in range(n-2, -1, -1):
    sum_arr[i] = sum_arr[i+1] + a[i]
print(a, sum_arr)
for i in range(n-1):
        prod_sum += a[i]*sum_arr[i+1]
print(prod_sum%(10**9+7))


Failing test case input:
4
2519048 2493 176 11813

Expected output:
512820549


Actual output:
[2519048, 2493, 176, 11813] [2533530, 14482, 11989, 11813]
512820549


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
prod_sum = 0
sum_arr = [0]*n
sum_arr[n-1] = a[n-1]
for i in range(n-2, -1, -1):
    sum_arr[i] = sum_arr[i+1] + a[i]
for i in range(n-1):
        prod_sum += a[i]*sum_arr[i+1]
print(prod_sum%(10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
List = list(map(int, input().split()))
S=0
for i in range(len(List)):
    S+=List[i]
mod=10**9+7
S=S%mod
T=0
for i in range(len(List)):
    T+=List[i]*(S-List[i])
    T=T%mod
print(T/2)

Failing test case input:
4
27651699 119786 3133913 72528

Expected output:
210345254


Actual output:
210345254.0


Fixed submission (verdict: Accepted):
N=int(input())
List = list(map(int, input().split()))
S=0
for i in range(len(List)):
    S+=List[i]
mod=10**9+7
S=S%mod
T=0
s=0
for i in range(len(List)):
    s+=List[i]
    s=s%mod
    T+=List[i]*(S-s)
    T=T%mod
print(T)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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]

ans = 0
for i in range(n-1):
    ans += A[i]*(prodsum[-1]-prodsum[i])
    ans % MODINT
print(ans)


Failing test case input:
4
27651699 119786 2501999 47420

Expected output:
82206585


Actual output:
74232082726209


Fixed submission (verdict: Accepted):
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]

ans = 0
for i in range(n-1):
    ans += A[i]*(prodsum[-1]-prodsum[i])
print(ans%MODINT)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
Ai = list(map(int, input().split()))
sum_ans = sum(Ai)
ans = 0
mod = 100000007

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

Failing test case input:
4
3855157 98660 5782 12204

Expected output:
533702553


Actual output:
33674105


Fixed submission (verdict: Accepted):
n = int(input())
Ai = list(map(int, input().split()))

sum_ans = sum(Ai)
ans = 0
mod = 1000000007

for i in range(n-1):
    sum_ans -= Ai[i]
    ans += sum_ans * Ai[i]
    ans %= mod

print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product)

Failing test case input:
4
36257838 139427 593808 70292

Expected output:
485012386


Actual output:
29268485217262


Fixed submission (verdict: Accepted):
n=int(input())
L=[int(x) for x in input().split()]
sum=0
product=0
mod=1000000007
for i in range(n):
    sum+=L[i]%mod
for i in range(n-1):
    sum-=(L[i]%mod)
    product+=sum*(L[i]%mod)
print(product%mod)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
numbers = list(map(int, input().split()))
result = 0
sum_of_numbers = sum(numbers)
for i in range(n - 1):
    sum_of_numbers -= numbers[i]
    result += (numbers[i] * sum_of_numbers) % 1000000007
print(result)

Failing test case input:
4
141421356 2224125 4405286 176612

Expected output:
735073075


Actual output:
1735073082


Fixed submission (verdict: Accepted):
n = int(input())
numbers = list(map(int, input().split()))
result = 0
sum_of_numbers = sum(numbers)
for i in range(n - 1):
    sum_of_numbers -= numbers[i]
    result += numbers[i] * sum_of_numbers
    result %= 1000000007
print(result)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))


Failing test case input:
4
141421356 1512598 4405286 176612

Expected output:
478491412


Actual output:
869600484578612


Fixed submission (verdict: Accepted):
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:
    int_sum -= num
    sum_result += num * int_sum
print(sum_result % target)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]

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

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

Failing test case input:
4
14846625 119786 5164610 29158

Expected output:
73489651


Actual output:
[0, 14846625, 14966411, 20131021, 20160179]
343103034 343103034
483792328 140689294
1073489658 589697330
1073489658 0
1073489658


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]
m = 1000000007
ans = 0

b = [0]
for i in range(1,n+1):
  b.append((a[i-1] + b[i-1]) % m)

           
for i in range(n):
	p = b[n] - b[i+1]
	p *= a[i]
	p = p % m
	ans += p
	ans = ans % m
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
l=list(map(int,input().split()))
b=10**9+7
d=(sum(l)%b)**2%b
c=0
for i in range(N):
  c=(c+l[i]**2%b)%b
print(round((d-c)%b/2))

Failing test case input:
4
14846625 119786 2501999 47420

Expected output:
714899675


Actual output:
214899672


Fixed submission (verdict: Accepted):
N=int(input())
l=list(map(int,input().split()))
b=10**9+7
d=(sum(l))**2
c=0
for i in range(N):
  c=c+l[i]**2
print((d-c)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
line = list(map(int, input().split()))
a = 10**9 +7
total = sum(line)%a
output = 0
for i in range(N):
    output += line[i]*(total-line[i])%a
    output = output%a
print(int(output/2))

Failing test case input:
4
14846625 119786 2501999 47420

Expected output:
714899675


Actual output:
214899671


Fixed submission (verdict: Accepted):
N = int(input())
line = list(map(int, input().split()))
a = 2*(10**9 +7)
total = sum(line)%a
output = total**2 %a
for i in range(N):
    output = (output - (line[i]**2)%a)%a
print( int(output/2))
Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
alist = list(map(int,input().split()))
wa = sum(alist)
answer = 0
atai = 0
for i in range(n):
    atai = (wa - alist[i]) % (10**9 + 7)
    answer += atai * alist[i]
    answer = answer % (10**9 + 7)
print(int(answer * 0.5))

Failing test case input:
4
6341164 101747 435150 75715

Expected output:
599495990


Actual output:
99495986


Fixed submission (verdict: Accepted):
n = int(input())
alist = list(map(int,input().split()))
wa = sum(alist)
answer = 0
atai = wa
for i in range(n):
    atai -= alist[i]
    answer += atai * alist[i]
    answer = answer % (10**9 + 7)
print(answer)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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))

Failing test case input:
4
3646424 64145 903 8685

Expected output:
484643724


Actual output:
3896387


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
B = sum(A)
cnt = 0
for i in range(N-1):
    B -= A[i]
    cnt += A[i]*B

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
 

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
 
print(int(findProductSum(a, n))%10**9+7) 

Failing test case input:
4
3646424 64145 903 5951

Expected output:
337479346


Actual output:
337481166


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
 

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)
mod = 10**9+7
  
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
  
print(modinv(2)*int(findProductSum(a, n))%mod)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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]
    
ans = sum % (1.0e+9 + 7)

print(ans)

Failing test case input:
4
6341164 101747 435150 75715

Expected output:
599495990


Actual output:
599495990.0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
sum_a = 0
sum = 0

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

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

print(ans)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())

A = tuple(map(int, input().split()))

MOD = 10 ** 9 + 7
rev_sum_list = [0] * N
rev_sum_list[-1] = A[-1]
for i in range(N - 2, -1, -1):
    rev_sum_list[i] = (rev_sum_list[i + 1] + A[i]) % MOD
print(rev_sum_list)
ans = 0
for i in range(1, N):
    ans += A[i - 1] * rev_sum_list[i]
    ans %= MOD
print(ans)

Failing test case input:
4
141421356 22198551 4405286 176612

Expected output:
907440962


Actual output:
[168201805, 26780449, 4581898, 176612]
907440962


Fixed submission (verdict: Accepted):
N = int(input())

A = tuple(map(int, input().split()))

MOD = 10 ** 9 + 7
rev_sum_list = [0] * N
rev_sum_list[-1] = A[-1]
for i in range(N - 2, -1, -1):
    rev_sum_list[i] = (rev_sum_list[i + 1] + A[i]) % MOD

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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)

Failing test case input:
4
4932847 3416 189 33

Expected output:
946461856


Actual output:

Fixed submission (verdict: Accepted):
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)




    


if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import decimal
n = int(input())
a = list(map(int, input().split())) 

first = a[0]

ans = first*a[1]

print(ans)
for i in range(1, n-1):
    first += a[i]
    ans += first*a[i+1]

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

Failing test case input:
4
6341164 105854 435150 70292

Expected output:
418782092


Actual output:
671237574056
418782092


Fixed submission (verdict: Accepted):

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

first = a[0]

ans = first*a[1]

for i in range(1, n-1):
    first += a[i]
    ans += first*a[i+1]

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
lis = list(map(int, input().split()))
ans = 0
mod = 10 ** 9 + 7

for i in range(0, n):
  for j in range(1, n):
    if i >= j:
      continue
    else:
      ans = ans + (lis[i]*lis[j]) % mod

print(ans)

Failing test case input:
4
3646424 64145 178 11813

Expected output:
395401127


Actual output:
2395401141


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
s = [0]
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
  s.append(s[i]+a[i])

s.pop(0)

for x in range(0, n-1):
  ans = ans +(a[x]*(s[n-1]-s[x]))
  
print(ans%mod)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

total_A = 0
for i in range(N):
    total_A = (total_A + A[i]) % m

total = (total_A * total_A) % m

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

divide = (total - total_sq) % m
if divide < 0:
    divide += m

print(int(divide / 2))


Failing test case input:
4
28568719 211119 10406344 94229

Expected output:
766457999


Actual output:
266457995


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
m = 10 ** 9 + 7

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

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

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

print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
A_sum = sum(A[1:])

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

Failing test case input:
4
1069110 84292 143968 75715

Expected output:
400766328


Actual output:
2400766342


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
A_sum = sum(A[1:])

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

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

z = 0
for i in range(n):
    z += a[i]

y = ((z % 1000000007)** 2) % 1000000007

x = 0
for j in range(n):
    x += a[j] ** 2


p = int(((y - x) / 2) % 1000000007)
print(p)

Failing test case input:
4
3646424 64145 903 8685

Expected output:
484643724


Actual output:
984643727


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

z = 0
for i in range(n):
    z += a[i]
e = z % 2

y = (z ** 2) % 2000000014

x = 0
for j in range(n):
    x += a[j] ** 2
    x = x % 2000000014

w = int(((y - x) / 2) % 1000000007)
print(w)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
c=0
d=sum(A)
for i in range(0,N-1):
    c-=A[i]
    c+=A[i]*d
    if(c>10**9+7):
        c%=(10**9+7)
print(c)


Failing test case input:
4
2519048 3416 227 749

Expected output:
67162778


Actual output:
856809794


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
c=0
d=sum(A)
for i in range(0,N-1):
    d-=A[i]
    c+=A[i]*d
    if(c>10**9+7):
        c%=(10**9+7)
print(c)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
MOD=1000000007
N=input()
A = [int(x)%MOD for x in input().split()]
l=len(A)
s=0
for i in range(l):
    for j in range(i+1,l):
        s+=A[i]*A[j]
print(s)

Failing test case input:
4
2519048 3416 189 862

Expected output:
256340473


Actual output:
11256340550


Fixed submission (verdict: Accepted):
MOD=1000000007
N=input()
A = list(map(int,input().split()))
l=len(A)
s=0
B=sum(A)
for i in range(l):
    B-=A[i]
    s+=A[i]*B
print(s%MOD)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    s = sum(arr) % MOD

    for num in arr:
        ans = (ans + (s-num)*num) % MOD

    return (ans % MOD) 


N = readInt()
arr = readList()

print(solve(N, arr))


Failing test case input:
4
2519048 3416 189 985

Expected output:
566626792


Actual output:
133253577


Fixed submission (verdict: Accepted):

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


def readList():
    return list(map(int, input().strip().split()))


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    prefixSums = [0]

    for num in arr:
        prefixSums.append(prefixSums[-1] + num)

    for i, num in enumerate(arr):
        ans = (ans + num * (prefixSums[-1] - prefixSums[i+1])) % MOD

    return ans % MOD


N = readInt()
arr = readList()

print(solve(N, arr))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
l = int(input())
num = input().split(' ')
num = [int(i) for i in num]
ans = 0
s = sum(num)
for i in range(l):
    print(s)
    s -= num[i]
    ans += num[i] * s
    print(ans)
print(ans%(10**9+7))

Failing test case input:
4
8519677 3228 187 33

Expected output:
376562424


Actual output:
8523125
29375846296
3448
29376556456
220
29376562627
33
29376562627
376562424


Fixed submission (verdict: Accepted):
l = int(input())
num = input().split(' ')
num = [int(i) for i in num]
ans = 0
s = sum(num)
for i in range(l):
    s -= num[i]
    ans += num[i] * s
print(ans%(10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 * 7
s = sum(a)
ans = 0
for x in a:
  ans += (s-x) * x
  ans %= mod
print(ans)

Failing test case input:
4
36257838 139427 593808 70292

Expected output:
485012386


Actual output:
2970434524


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
invtwo = pow(2, mod-2, mod)
s = sum(a) % mod
ans = 0
for x in a:
  ans += (s-x) * x
  ans %= mod
print((ans * invtwo) % mod)