Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
p,S = 0,0
for i in range(N-1):
    ap = A.pop(0)
    AA = sum(A)
    aa = ap*AA
    a = aa%1000000007
    S += a
p = S%1000000007
print(p)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
p,S = 0,0
for i in range(N-1):
    ap = A.pop(0)
    AA = sum(A)
    aa = ap*AA
    a = aa%1000000007
    S += a
p = S%1000000007
print(p)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)

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

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
a,s = 0,0
for i in range(N):
    a += s*A[i]
    s += A[i]
    a %= mod
print(a)