n=gets.to_i
a=gets.split.map(&:to_i)
INF=10**9+7
result=0
a_sum=a.inject(&:+)

s=[]
s[0]=a_sum
for i in 0..a.length-1
    s[i+1]=s[i]-a[i]
end

result=0
for i in 0..a.length-1
    result+=a[i]*s[i+1]
    result%=INF
end
p result