Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    newcur = 0 
    for j in range(i + 1, n):
        newcur += arr[j]
    newcur  = newcur % 1000000007
    ans += curnum * newcur
    if ans >= 1000000007:
        ans = ans % 1000000007

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
total = []
curtotal = sum(arr)
total.append(curtotal)
for i in range(n):
    curtotal -= arr[i]
    total.append(curtotal)
for i in range(n):
    total[i] = total[i] % 1000000007

for i in range(n - 1):
    curnum = arr[i]
    tempans = curnum * total[i + 1]
    if tempans >= 1000000007:
        tempans = tempans % 1000000007
    ans += tempans

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    for j in range(i + 1, n):
        ans += curnum * arr[j]
        if ans >= 1000000007:
            ans = ans % 1000000007

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
total = []
curtotal = sum(arr)
total.append(curtotal)
for i in range(n):
    curtotal -= arr[i]
    total.append(curtotal)
for i in range(n):
    total[i] = total[i] % 1000000007

for i in range(n - 1):
    curnum = arr[i]
    tempans = curnum * total[i + 1]
    if tempans >= 1000000007:
        tempans = tempans % 1000000007
    ans += tempans

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    for j in range(i + 1, n):
        ans += curnum * arr[j]
        if ans >= 1000000007:
            ans = ans % 1000000007

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
total = []
curtotal = sum(arr)
total.append(curtotal)
for i in range(n):
    curtotal -= arr[i]
    total.append(curtotal)
for i in range(n):
    total[i] = total[i] % 1000000007

for i in range(n - 1):
    curnum = arr[i]
    tempans = curnum * total[i + 1]
    if tempans >= 1000000007:
        tempans = tempans % 1000000007
    ans += tempans

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i))
    
ans = 0 
for i in range(n - 1):
    curnum = arr[i]
    for j in range(i + 1, n):
        ans += curnum * arr[j]
        if ans >= 1000000007:
            ans -= 1000000007

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)

Fixed submission:
n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
for i in temparr:
    arr.append(int(i)  % 1000000007)
    
ans = 0 
total = []
curtotal = sum(arr)
total.append(curtotal)
for i in range(n):
    curtotal -= arr[i]
    total.append(curtotal)
for i in range(n):
    total[i] = total[i] % 1000000007

for i in range(n - 1):
    curnum = arr[i]
    tempans = curnum * total[i + 1]
    if tempans >= 1000000007:
        tempans = tempans % 1000000007
    ans += tempans

if ans >= 1000000007:
    print(ans % 1000000007)
else:
    print(ans)