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

tot = 0
num2 = [0]*(N-1)

for i in range(len(num)-1):
  num2[i] = sum(num[1+i:]) % (10**9+7)
  
for i in range(len(num)-1):
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

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

tot = 0
num2 = [0]*(N-1)


for i in range(len(num)-1):
  num1 = num[i] % (10**9+7)
  num2[i] = sum(num[1+i:]) % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

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

tot = 0

for i in range(len(num)):
  num2 = sum(num[i+1:])
  #print(num2)  

  tot += (num[i] % (10**9+7)) * (num2 % (10**9+7))
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

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

tot=0

for i in range(len(num)):

  tot += (num[i] % (10**9+7) * sum(num[i+1:]) % (10**9+7))
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

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

tot=0

for i in range(len(num)):

  tot += (num[i] % (10**9+7) * sum(num[i+1:]) % (10**9+7))
  tot = tot % (10**9+7)

print(tot)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)

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

sum=0

for i in range(len(num)):
  for j in num[i+1:]:
    sum += (num[i] * j % (10**9+7))
    sum = sum % (10**9+7)
    
print(sum)

Fixed submission:
N = int(input())
num = list(map(int, input().split()))

tot = 0
num2 = [0]*(N-1)
numtot = sum(num)

for i in range(len(num)-1):
  numtot -= num[i]
  num2[i] = numtot % (10**9+7)
  
  num1 = num[i] % (10**9+7)
  
  tot += num1 * num2[i]
  
  if tot >= (10**9+7): tot = tot % (10**9+7)

print(tot)