Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from sys import stdin
input = stdin.readline

n = int(input().rstrip())
a_row = list(map(int, input().rstrip().split()))

a = np.array(a_row)
MOD = 1000000007
ans = 0

for i in range(n-1):
    ans += (a[i] % MOD) * (np.sum(a[i+1:n]) % MOD)
    ans = ans % MOD

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

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

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

for i in range(n):
    a[i] = a[i] % MOD

for i in range(n-1):
    for j in range(i+1, n):
        ans += a[i] * a[j]
        ans = ans % MOD

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i] % MOD) * (a[j] % MOD)
        ans = ans % MOD

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

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

MOD = 1000000007
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i] % MOD) * (a[j] % MOD)
        ans = ans % MOD

print(ans)

Fixed submission:
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)

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

MOD = 1000000007
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        ans += a[i] * a[j]

print(ans % MOD)

Fixed submission:
from sys import stdin
input = stdin.readline

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

MOD = 1000000007
ans = 0

k = 0
s = [0] * n
for i in range(n-1, 0, -1):
    k += a[i] % MOD
    s[i] = k

for i in range(n-1):
    ans += a[i] * s[i+1]

ans = ans % MOD

print(ans)