Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def main(N, A_list):
    num = len(A_list)
    tmp = []
    for i in range(0, num, 1):
        for j in range(i+1, num, 1):
            tmp.append(A_list[i] * A_list[j])

    val = sum(tmp) % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Fixed submission:
# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def main(N, A_list):
    mod = (10 ** 9) + 7
    tmp = []
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            tmp.append(A_list[i] * A_list[j])

    val = 0
    for x in tmp:
        val += x

    print(val % mod)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Fixed submission:
# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def main(N, A_list):
    val = 0
    mod = (10 ** 9) + 7
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            val += A_list[i] * A_list[j]

    print(val % mod)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Fixed submission:
# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def main(N, A_list):
    val = 0
    mod = (10 ** 9) + 7
    for i in range(len(A_list)):
        for j in range(i+1, len(A_list), 1):
            val = (val + (A_list[i] * A_list[j])) % mod
    
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)

Fixed submission:
# -*- coding: utf-8 -*-

def main(N, A_list):
    total_list = []
    total = 0
    for i in range(len(A_list)):
        total += A_list[i]
        total_list.append(total)

    num = 0
    for i in range(len(A_list)-1):
        num += A_list[i] * (total_list[len(A_list)-1]-total_list[i])

    val = num % ((10 ** 9) + 7)
    print(val)


N = int(input())
A_list = list(map(int, input().split()))
main(N, A_list)