Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
 
answer = 0
mod = 1000000007
for i in range(N-1):
  total = sum(A[i+1:])
  multi = A[i] * total
  answer += multi
print(str(answer % mod))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

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

answer = 0
mod = 1000000007
for i in range(N-1):
  total = sum(A[i+1:])
  multi = ((A[i] % mod) * (total % mod)) % mod
  answer = (answer + multi) % mod
print(str(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

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

answer = 0
mod = 1000000007
for i in range(N-1):
  total = 0
  for j in range(i+1, N):
    total += A[j]
  multi = ((A[i] % mod) * (total % mod)) % mod
  answer = (answer + multi) % mod
print(str(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

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

answer = 0
mod = 1000000007
for i in range(N-1):
  for j in range(i+1, N):
    answer += ((A[i] % mod) * (A[j] % mod)) % mod
    answer %= mod
print(int(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

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

answer = 0
mod = 1000000007
for i in range(N-1):
  for j in range(i+1, N):
    answer += (A[i] * A[j]) % mod
    answer %= mod
print(int(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

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

answer = 0
mod = 1000000007
for i in range(N-1):
  for j in range(i+1, N):
    answer += A[i] * A[j]
    answer %= mod
print(int(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

Buggy python submission (verdict: Time Limit Exceeded):

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

answer = 0
mod = 1000000007
for i in range(N-1):
  for j in range(i+1, N):
    answer += A[i] * A[j]
    answer %= mod
print(int(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

Buggy python submission (verdict: Time Limit Exceeded):


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

answer = 0
mod = 10**9 + 7
for i in range(N):
  for j in range(i+1, N):
    multi = (A[i] * A[j])
    answer += multi
    answer = answer % mod
print(int(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))

Buggy python submission (verdict: Time Limit Exceeded):

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

answer = 0
mod = 10**9 + 7
for i in range(N):
  for j in range(i+1, N):
    multi = (A[i] * A[j])
    answer += multi
answer = answer % mod
print(int(answer))

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

answer = 0
a_sum = sum(A)
mod = 10**9+7

for i in range(N-1):
  a_sum -= A[i]
  answer += a_sum * A[i]
print(str(answer % mod))