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


Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

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

Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

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

Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
# for i in range(0, N-1):
#     A[i] = A[i] % MOD
#print(A)
for i in range(0, N-1):
    A[i] = A[i] % MOD
    for j in range(i+1, N):
        #print(i, j)
        # temp1 = 0
        # temp2 = 0
        temp3 = 0
        # temp1 = A[i] % MOD
        # temp2 = A[j] % MOD
        # temp3 = temp1 * temp2
        temp3 = (A[i] * A[j]) % MOD
        sum = (sum + temp3) % MOD
#sum = sum % MOD
print(sum)

Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
for i in range(0, N-1):
    A[i] = A[i] % MOD
#print(A)
for i in range(0, N-1):
    for j in range(i+1, N):
        #print(i, j)
        temp1 = 0
        temp2 = 0
        temp3 = 0
        # temp1 = A[i] % MOD
        # temp2 = A[j] % MOD
        # temp3 = temp1 * temp2
        temp3 = (A[i] * A[j]) % MOD
        sum = (sum + temp3) % MOD
#sum = sum % MOD
print(sum)

Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
for i in range(0, N-1):
    for j in range(i+1, N):
        #print(i, j)
        temp1 = 0
        temp2 = 0
        temp3 = 0
        temp1 = A[i] % MOD
        temp2 = A[j] % MOD
        temp3 = temp1 * temp2
        sum = (sum + temp3) % MOD
#sum = sum % MOD
print(sum)

Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
sum = 0
# temp1 = 0
# temp2 = 0
MOD = 1000000007
for i in range(0, N-1):
    for j in range(i+1, N):
        #print(i, j)
        temp1 = 0
        temp2 = 0
        temp3 = 0
        temp1 = A[i] % MOD
        temp2 = A[j] % MOD
        temp3 = temp1 * temp2
        sum = sum + temp3
sum = sum % MOD
print(sum)

Fixed submission:
MOD = 1000000007
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = [0]*(N-1)
sumA = sum(A)
for i in range(1, N):
    sumA -= A[i-1]
    B[i-1] = sumA
for i in range(0, N-1):
    ans += A[i] * B[i]
    ans %= MOD
print(ans)