console.log((args=>{
  const [[N],A] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  const MOD = 1e9+7;
  const mul = (a,b) => ((a>>16)*b%MOD*65536+(a&65535)*b)%MOD;
  let sum = 0, sub = A.reduce((a,b)=>(a+b)%MOD);
  for ( let i = 0; i < N; i++ ) {
    sub = ( sub + MOD - A[i] ) % MOD;
    sum = (sum + mul(A[i],sub)) % MOD;
  }
  return sum;
})(require('fs').readFileSync('/dev/stdin','utf8')));
