#!/usr/bin/env python



n = int(eval(input()))

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



mod = int(1e9)+7



total = sum(a)

ans = 0 

for i in range(n):

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

    total -= a[i]



print((ans%mod))

#!/usr/bin/env python



n = int(eval(input()))

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

mod = int(1e9)+7



s = sum(a)

ans = sub = 0 

for i in range(n):

    ans += a[i]*s

for i in range(n):

    sub += a[i]*a[i]

ans = ((ans-sub)//2)%mod

print(ans)

#!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))
mod = int(1e9) + 7
total = sum(a)
ans = 0
for i in range(n):
    ans += (a[i] * (total - a[i])) % mod
    total -= a[i]
print((ans % mod))

#!/usr/bin/env python
n = int(eval(input()))
a = list(map(int, input().split()))
mod = int(1e9) + 7
s = sum(a)
ans = sub = 0
for i in range(n):
    ans += a[i] * s
for i in range(n):
    sub += a[i] * a[i]
ans = ((ans - sub) // 2) % mod
print(ans)

-total = sum(a) -ans = 0 +s = sum(a) +ans = sub = 0 -    ans += (a[i] * (total - a[i])) % mod -    total -= a[i] -print((ans % mod)) +    ans += a[i] * s +for i in range(n): +    sub += a[i] * a[i] +ans = ((ans - sub) // 2) % mod +print(ans)