Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
num_list = input().split()

mod_base = 10 ** 9 + 7

num_list = [int(x) for x in num_list]

def calc_list(i, num_list):
    return num_list[i] * sum(num_list[i+1:])

sum_num = 0

for i, num_str in enumerate(num_list):
    if i+1 > len(num_list):
        break
    sum_num += calc_list(i, num_list)
    
print(sum_num % mod_base)

Fixed submission:
import itertools

n = int(input())
num_list = input().split()

mod_base = 10 ** 9 + 7

num_list = [int(x) for x in num_list]

sum_list = []
sum_tmp = sum(num_list)
for i in range(len(num_list)):
    sum_list.append(sum_tmp)
    sum_tmp -= num_list[i]

all_sum = 0
for index, num in enumerate(num_list):
    if index + 1 >= len(num_list):
        break
    all_sum += num * sum_list[index+1]

print(all_sum % mod_base)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
num_list = input().split()

mod_base = 10 ** 9 + 7

def calc_list(i, num_list):
    sum = 0
    for num in num_list[i+1:]:
        sum += int(num_list[i]) * int(num)
    return sum

sum_num = 0

for i, num_str in enumerate(num_list):
    if i+1 > len(num_list):
        break
    sum_num += calc_list(i, num_list)
    
print(sum_num % mod_base)

Fixed submission:
import itertools

n = int(input())
num_list = input().split()

mod_base = 10 ** 9 + 7

num_list = [int(x) for x in num_list]

sum_list = []
sum_tmp = sum(num_list)
for i in range(len(num_list)):
    sum_list.append(sum_tmp)
    sum_tmp -= num_list[i]

all_sum = 0
for index, num in enumerate(num_list):
    if index + 1 >= len(num_list):
        break
    all_sum += num * sum_list[index+1]

print(all_sum % mod_base)

Buggy python submission (verdict: Runtime Error):
#標準入力
N = int(input())
A = list(map(int, input().split()))
 
#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]
  
_sum = int(0)
for i in range(N-1):
  _sum = _sum + int((A[i] * (S[N] - S[i])))

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Buggy python submission (verdict: Runtime Error):
#標準入力
N = int(input())
A = list(map(int, input().split()))
 
#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]
  
_sum = 0
for i in range(N-1):
  _sum = _sum + (A[i] * (S[N] - S[i+1]))

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Buggy python submission (verdict: Runtime Error):
#標準入力
N = int(input())
A = list(map(int, input().split()))
 
#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]
  
_sum = 0
for i in range(N-1):
  _sum = _sum + (A[i] * (S[N] - S[i+1]))
  _sum = _sum % (1000000000+7)
  
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Buggy python submission (verdict: Runtime Error):
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
	S[n] = S[n-1] + A[n]

_sum = 0
for i in range(N-1):
  _sum = _sum + (A[i] * (S[N] - S[i+1]))
  _sum = _sum % (1000000000+7)
  
print(_sum)


Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Buggy python submission (verdict: Time Limit Exceeded):
#標準入力
N = int(input())
A = list(map(int, input().split()))

A = list(map(lambda x: x%(1000000000+7), A))
_sum = 0
 
for n in range(N-1):
  for i in range(n+1):
    _sum = _sum + (A[n+1] * A[i])
    _sum = _sum % (1000000000+7)
    
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
A = A % (1000000000+7)
_sum = 0
 
for n in range(N-1):
  for i in range(n+1):
    _sum = _sum + (A[n+1] * A[i])
    _sum = _sum % (1000000000+7)
    
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

Buggy python submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
A = np.array(map(int, input().split()))
 
A %= (1000000000+7)
_sum = 0
 
for n in range(N-1):
  for i in range(n+1):
    _sum += A[n+1] * A[i]
    _sum %= (1000000000+7)
    
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)

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

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

A %= (1000000000+7)
_sum = 0

for n in range(N-1):
  for i in range(n+1):
    _sum += A[n+1] * A[i]
    _sum = %= (1000000000+7)
    
print(_sum)

Fixed submission:
#標準入力
N = int(input())
A = list(map(int, input().split()))

#累積和
S = [0]*N
for n in range(N):
  S[n] = S[n-1] + A[n]

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

#modulo
_sum = _sum % (1000000000+7)
  
print(_sum)