def main():

    n = int(eval(input()))

    a_list = list(map(int, input().split()))



    sum_list = [0 for _ in range(n)]

    sum_list[0] = sum(a_list)

    ans = 0



    for i in range(1, n):

        sum_list[i] = sum_list[i - 1] - a_list[i - 1]



    for i in range(n - 1):

        ans += a_list[i] * sum_list[i + 1] % (10 ** 9 + 7)



    print((ans % (10 ** 9 + 7)))





if __name__ == "__main__":

    main()

def main():

    n = int(eval(input()))

    a_list = list(map(int, input().split()))

    mod = 10 ** 9 + 7

    sum_a = sum(a_list)

    ans = 0



    for i in range(n - 1):

        sum_a -= a_list[i]

        ans += (a_list[i] * sum_a) % mod



    print((ans % mod))





if __name__ == "__main__":

    main()

def main():
    n = int(eval(input()))
    a_list = list(map(int, input().split()))
    sum_list = [0 for _ in range(n)]
    sum_list[0] = sum(a_list)
    ans = 0
    for i in range(1, n):
        sum_list[i] = sum_list[i - 1] - a_list[i - 1]
    for i in range(n - 1):
        ans += a_list[i] * sum_list[i + 1] % (10**9 + 7)
    print((ans % (10**9 + 7)))


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    a_list = list(map(int, input().split()))
    mod = 10**9 + 7
    sum_a = sum(a_list)
    ans = 0
    for i in range(n - 1):
        sum_a -= a_list[i]
        ans += (a_list[i] * sum_a) % mod
    print((ans % mod))


if __name__ == "__main__":
    main()

-    sum_list = [0 for _ in range(n)] -    sum_list[0] = sum(a_list) +    mod = 10**9 + 7 +    sum_a = sum(a_list) -    for i in range(1, n): -        sum_list[i] = sum_list[i - 1] - a_list[i - 1] -        ans += a_list[i] * sum_list[i + 1] % (10**9 + 7) -    print((ans % (10**9 + 7))) +        sum_a -= a_list[i] +        ans += (a_list[i] * sum_a) % mod +    print((ans % mod))