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

m = 10 ** 9 + 7
def main():
    r = 0
    for nn in range(n):
        r += a[nn] * sum(a[nn+1:])
    print(r % m)
    return

main()


Fixed submission:
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(int(n / 2)):
        r += ((a[i] % m) * (sum(a[i+1:]) % m))
    
    for i in range(int(n / 2), n-1):
        r += ((a[i] % m) * (sum(a[i+1:]) % m))
    print(r % m)
    return

main()


Fixed submission:
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(n - 1):
        r += ((a[i] % m) * (sum(a[i+1:]) % m))
    print(r % m)
    return

main()


Fixed submission:
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(n - 1):
        r += a[i] * sum(a[i+1:])
    
    print(r % m)
    return

main()


Fixed submission:
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            r += (a[i] % m) * (a[j] % m)

    print(r % m)
    return

main()


Fixed submission:
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(n - 1):
        for j in range(i+1, n):
            r += (a[i] * a[j])
    
    print(r % m)
    return

main()


Fixed submission:
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()