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)
for (let i=0; i+1<s; i++){
  let target = w[i]
  all = all - w[i]
  let sum = target * all
  total=total+sum
  ans = total % mod
  }
console.log(ans)
