n=gets.to_i
mod = 10**9+7
a=gets.split.map &:to_i
ans=0
(a.length-1).times do |i|
  ans += a[i] * (a[i+1, a.length-i+1].sum)
  #puts "a[i]: #{a[i]}, a[i+j+1]: #{a[i+j+1]}, ans: #{ans}"
end
p ans % mod
