Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [ int(i) for i in input().split() ]
count = 0
for i in range(len(lst)):
    c = 0
    for j in range(i+1, len(lst)):
        c += lst[j]
    count += c * lst[i]
    
mod = 10**9 +7
if count >= mod:
    print(count%mod)
else:
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)

Buggy python submission (verdict: Runtime Error):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = list(set(lst))

for i in range(len(lst)):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)

Buggy python submission (verdict: Runtime Error):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    if lst[i] not in d_lst:
        if lst[i] == lst[i+1]:
            d_lst.append(lst[i])
for d in d_lst:
    count += d**2
lst = set(lst)

for i in range(len(lst)):
    for j in range(i+1,len(lst)):
        a = lst[i] * lst[j]
        count += a

if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    for j in range(i+1,len(lst)):
    # print(i,j)
        a = lst[i] * lst[j]
        if lst[j] in d_lst:
            continue
        else:
            if lst[i] == lst[j]:
                d_lst.append(lst[j])
                count += a
            else:
                count += a
    
if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)

Buggy python submission (verdict: Runtime Error):
n= int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
count = 0
d_lst = []
for i in range(len(lst)):
    for j in range(i+1,len(lst)):
    # print(i,j)
        a = lst[i] * lst[j]
        if lst[j] in d_lst:
            continue
        else:
            if lst[i] == lst[j]:
                d_lst.apend(lst[j])
                count += a
            else:
                count += a
    
if count > ( 10**9 + 7 ):
    print(count % (10**9 + 7))
else:
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ruiseki = 0
count = 0
for i in range(n-1):
    ruiseki += a[i]
    count += ruiseki * a[i+1]
mod = 10**9 + 7
if count >= mod:
    print(count%mod)
else:
    print(count)