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

ans = 0
mod = 10**9+7
# for i in range(N-1):
#     for j in range(i+1,N):
#         ans += (A[i]%mod) * (A[j]%mod)
#         ans %= mod

A = list(map(lambda x: x %mod,A))
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j]
        ans %= mod
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

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

ans = 0
mod = 10**9+7
# for i in range(N-1):
#     for j in range(i+1,N):
#         ans += (A[i]%mod) * (A[j]%mod)
#         ans %= mod

# A = list(map(lambda x: x %mod,A))
for i in range(N-1):
    for j in range(i+1,N):
        ans += A[i] * A[j]
        ans %= mod
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

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

ans = 0
mod = 10**9+7
# for i in range(N-1):
#     for j in range(i+1,N):
#         ans += (A[i]%mod) * (A[j]%mod)
#         ans %= mod

A = list(map(lambda x: x %mod,A))
for i in range(N-1):
    for j in range(i+1,N):
        ans += (A[i]) * (A[j])
        ans %= mod
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

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

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

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

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

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

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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

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

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)

# 累積和を使う
for i in range(1,N+1):
    B[i] = A[i-1]+B[i-1]
# 累積和の配列完成
# print(B) 

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