Buggy python submission (verdict: Runtime Error):
import numpy as np

MOD = 10 ** 9 + 7

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

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [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)

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
MOD = 10 ** 9 + 7

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

total=np.sum(alst) #6
sum=0

for i in range(n-1):
  for j in range(i+1,n):
    sum=sum+alst[i]*alst[j]
    sum%=MOD

print(sum)

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
d=list(map(int,input().split()))

sum=0
mod = 1000000007

for i in range(a-1):
  for j in range(i+1,a):
    sum=pow(sum+d[i]*d[j],1,mod)

print(sum)

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
#pragma GCC optimize("Ofast")

a=int(input())

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

sum=0
mod = 10**9+7

for i in range(a-1):
  for j in range(i+1,a):
    sum=pow(sum+d[i]*d[j],1,mod)

print(sum)

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
#pragma GCC optimize("Ofast")

a=int(input())

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

sum=0
mod = pow(10,9)+7

for i in range(a-1):
  for j in range(i+1,a):
    sum=pow(sum+d[i]*d[j],1,mod)

print(sum)

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
#pragma GCC optimize("Ofast")

a=int(input())

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

sum=0
b=0
mod = pow(10,9)+7

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]
    b=pow(sum,1,mod)

print(b)

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
#pragma GCC optimize("Ofast")

a=int(input())

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


w=[]

for i in range(a-1):
  for j in range(i+1,a):
    w.append(d[i]*d[j])

sum=sum(w)
mod = pow(10,9)+7
print(pow(sum,1,mod))

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
#pragma GCC optimize("Ofast")

a=int(input())

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

sum=0

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]

mod = pow(10,9)+7
print(pow(sum,1,mod))

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
#pragma GCC optimize("Ofast")

a=int(input())

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

sum=0

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]

print(sum%(pow(10,9)+7))

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())

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

sum=0

def pow_r(x, n):
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]

print(sum%(pow_r(10,9)+7))

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())

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

sum=0

for i in range(a-1):
  for j in range(i+1,a):
    sum=sum+d[i]*d[j]

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

Fixed submission:
MOD = 10 ** 9 + 7

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

total=sum(alst)
sum=0

# for i in range(n-1):
#   for j in range(i+1,n):
#     sum=pow(sum+alst[i]*alst[j],1,MOD)

# print(sum)

for a in alst:
  sum = sum+a * (total - a)
  sum %= MOD

sum *= pow(2, MOD - 2, MOD)
sum %= MOD
print(sum)

Buggy python submission (verdict: Runtime Error):
for i in range (N):
    A = (int(input())
MASS = 0
for i in range (N - 1):
    T = 0
    for j in range (i + 1, N):
        T += (A[j] % NUM)
    MASS += ((A[i]%NUM) * (T%NUM))%NUM
print(MASS % NUM)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
total = 0
sub = 0
for i in a:
    total += i
    sub += i * i
print((((total * total) - sub) // 2) % (10 ** 9 + 7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
NUM = 1000000007
A = [int(input()) for _ in range(N)]
MASS = 0
for i in range (N):
    I = A[i] % NUM
    I = (I * (N - 1)) % NUM
    MASS += I
print(MASS % NUM)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
total = 0
sub = 0
for i in a:
    total += i
    sub += i * i
print((((total * total) - sub) // 2) % (10 ** 9 + 7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
NUM = 1000000007
A = [list(map(int, input().split())) for _ in range(N)]
MASS = 0
for i in range (N):
    I = A[i] % NUM
    I = (I * (N - 1)) % NUM
    MASS += I
print(MASS % NUM)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
total = 0
sub = 0
for i in a:
    total += i
    sub += i * i
print((((total * total) - sub) // 2) % (10 ** 9 + 7))