

from itertools import accumulate

def resolve():

    MOD = 10**9+7

    N = int(eval(input()))

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



    Acc = [0] + list(accumulate(A))



    ans = 0

    for i in range(N):

        ans += A[i] * (Acc[N] - Acc[i+1])

        ans %= MOD



    print(ans)





if __name__ == "__main__":

    resolve()



def resolve():

    MOD = 10 ** 9 + 7

    N = int(eval(input()))

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



    # 面積として見る: 縦*横

    square = sum(A) ** 2



    # 対角線

    diag = sum([a * a for a in A])



    ans = (square - diag) // 2

    print((ans % MOD))





if __name__ == "__main__":

    resolve()
from itertools import accumulate


def resolve():
    MOD = 10**9 + 7
    N = int(eval(input()))
    A = list(map(int, input().split()))
    Acc = [0] + list(accumulate(A))
    ans = 0
    for i in range(N):
        ans += A[i] * (Acc[N] - Acc[i + 1])
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    resolve()

def resolve():
    MOD = 10**9 + 7
    N = int(eval(input()))
    A = list(map(int, input().split()))
    # 面積として見る: 縦*横
    square = sum(A) ** 2
    # 対角線
    diag = sum([a * a for a in A])
    ans = (square - diag) // 2
    print((ans % MOD))


if __name__ == "__main__":
    resolve()

-from itertools import accumulate - - -    Acc = [0] + list(accumulate(A)) -    ans = 0 -    for i in range(N): -        ans += A[i] * (Acc[N] - Acc[i + 1]) -        ans %= MOD -    print(ans) +    # 面積として見る: 縦*横 +    square = sum(A) ** 2 +    # 対角線 +    diag = sum([a * a for a in A]) +    ans = (square - diag) // 2 +    print((ans % MOD))