Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

a = [i for i in a if i != 0]

ans = 0
alist = []
for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        t = (a[i] * a[j]) % dx
        alist.append(t)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

a = [i % dx for i in a if i != 0]

ans = 0
alist = []
for i in range(len(a)):
    for j in range(i+1, len(a)):
        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

a = [i % dx for i in a if i != 0]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

# b = [i % dx for i in a]

ans = 0
alist = []
for i in range(n):
    if a[i] == 0:
        continue

    for j in range(i+1, n):
        if a[j] == 0:
            continue

        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

# b = [i % dx for i in a]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((a[i] * a[j]) % dx)

for i in range(len(alist)):
    ans += alist[i]
    ans %= dx

ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = (list(map(int, input().split())))
dx = 10 ** 9 + 7

b = [i % dx for i in a]

ans = 0
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((b[i] * b[j]) % dx)

ans = sum(alist)
ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = (list(map(int, input().split())))

ans = 0
dx = 10 ** 9 + 7
alist = []
for i in range(n):
    for j in range(i+1, n):
        alist.append((a[i] * a[j]) % dx)

ans = sum(alist)
ans %= dx
print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = (list(map(int, input().split())))

ans = 0
dx = 10 ** 9 + 7
for i in range(n):
    for j in range(i+1, n):
        ans += a[i] * a[j]
        ans %= dx

print(ans)


Fixed submission:
n = int(input())

a = list(map(int, input().split()))

S = sum(a)

S2 = sum(map(lambda x: x * x, a ))

ans = (S * S - S2) // 2 % 1000000007
print(ans)