N = int(input())
A = list(map(int, input().split()))
diff = A[0]
res = 0
for i in range(1, N):
    res += diff * A[i]
    diff += A[i]
    res %= 10 ** 9 + 7
    diff %= 10 ** 9 + 7
print(res)

aac7786528bf8c807b119cdfac4a44b8abee2049
<mask token>

<mask token>
for i in range(1, N):
    res += diff * A[i]
    diff += A[i]
    res %= 10 ** 9 + 7
    diff %= 10 ** 9 + 7
print(res)

N = int(input())
A = list(map(int, input().split()))
diff = A[0]
res = 0
for i in range(1, N):
    res += diff * A[i]
    diff += A[i]
    res %= 10 ** 9 + 7
    diff %= 10 ** 9 + 7
print(res)
