Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
 
ans = 0
for i in range(n):
    plus = sum(a[i+1:])%MOD
    ans += a[i]*plus
    ans %= MOD
 
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
b = [(sum(a[:n-i-1])* a[n-i-1])%MOD for i in range(n-1)]
print(sum(b)%MOD)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
b = [(sum(a[:n-i-1])* a[n-i-1])%MOD for i in range(n-1)]
print(sum(b)%MOD)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    plus = sum(a[i+1:])%MOD
    ans += a[i]*plus
    ans %= MOD

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    plus = 0
    for j in range(i, n):
        if i == j:
            continue
        plus += a[j]%MOD
    ans += a[i]*plus 
    ans %= MOD
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    plus = 0
    for j in range(i, n):
        if i == j:
            continue
        plus += a[j]
    ans += a[i]*plus 
    ans %= MOD
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
#n = 4
#a = [141421356, 17320508, 22360679, 244949]
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    for j in range(i, n):
        if i == j:
            continue
        ans += (a[i]*a[j])
print(ans%MOD)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
#n = 4
#a = [141421356, 17320508, 22360679, 244949]
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in range(n):
    for j in range(i, n):
        if i == j:
            continue
        ans += (a[i]*a[j])
        ans %= MOD

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
#n = 4
#a = [141421356, 17320508, 22360679, 244949]
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

ans = 0
for i in itertools.combinations(a, 2):
    ans += (i[0]*i[1])
    ans %= MOD

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
ans = 0
plus = 0
for i in range(n-1):
    plus += a[n-i-1]
    plus %= MOD
    ans += a[n-i-2]*plus
    ans %= MOD
print(ans%MOD)