N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)%(1000000007)
square = 0
for i in range(N):
    square -=  ( (A[i]%(1000000007))**2 ) % (1000000007)
    if square < 0:
      square = square + 1000000007
res = ( ((sumA * sumA + square)%(1000000007))*((1000000007+1)/2) ) % 1000000007
print(round(res))