function Main(input) {
  const lines = input.split('\n');
  const N = lines[0];
  const A = lines[1].split(' ').map(i => parseInt(i));
  const D = Math.pow(10, 9) + 7;
  const notes = [];
  let sum = 0;
  A.reverse().map(a => {
    sum += a;
    sum = sum % D;
    notes.push(sum);
  });
  notes.reverse();
  A.reverse();
  console.log(A);
  console.log(notes);
  sum = 0;
  A.forEach((a, i) => {
    if (i !== N - 1) {
      console.log(a, notes[i+1]);
      sum += (a * notes[i+1]) % D;
    }
  });
  console.log(sum % D);
}

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