n = gets.to_i
a = gets.split(" ").map(&:to_i)
sum=0

sum_tmp=0

a[0]=a[0]%(1000000007)

for i in 1..n-1
  a[i]=a[i]%(1000000007)
  sum_tmp+=a[i]
end

for i in 0..n-2
  sum=(sum+a[i]*(sum_tmp))
  sum_tmp=sum_tmp-a[i+1]
end
sum=sum%(1000000007)

puts sum