from itertools import accumulate

def main():

    mod=10**9+7

    n=int(eval(input()))

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

    aa=[0]+list(accumulate(a))

    ans=0

    for i in range(n-1):

        ans += a[i]*(aa[-1]-aa[i+1])%mod

    print((ans%mod))



if __name__ == '__main__':

    main()
from itertools import accumulate

def main():

    n=int(eval(input()))

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

    aa=list(accumulate(a))

    mod=10**9+7

    ans=0

    for i in range(n):

        ans += a[i]*(aa[-1]-aa[i])%mod

    print((ans%mod))

    

if __name__ == "__main__":

    main()
from itertools import accumulate


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


if __name__ == "__main__":
    main()

from itertools import accumulate


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


if __name__ == "__main__":
    main()

-    mod = 10**9 + 7 -    aa = [0] + list(accumulate(a)) +    aa = list(accumulate(a)) +    mod = 10**9 + 7 -    for i in range(n - 1): -        ans += a[i] * (aa[-1] - aa[i + 1]) % mod +    for i in range(n): +        ans += a[i] * (aa[-1] - aa[i]) % mod