var stdin = require("fs").readFileSync("/dev/stdin", "utf8");

var a =  stdin.split("\n")
var s = a[0]
var w= a[1].split(' ').map( str => parseInt(str, 10));
var mod = 1000000007;
//const w = t.split(' ');
//var all = array.reduce(reducer,0)
let total=0;
let ans = 0;
//var all = w.reduce((a,x) => a+=x)
let array =[0]

for (let i=0;i+1<=s; i++){
let plus = array[i]+w[i]
array.push(plus)
}
//console.log(array)
var x = array [array.length - 1]
for (let i=0; i<s-1; i++){
  let target = w[i]
  //all = all - w[i]
  var y = array [i+1]

  let sum = target * (x-y)
  total=total+sum
  ans = total % mod
  }
console.log(ans)
