((input) => {
  const arr = input.trim().split('\n')[1].split(' ').map(Number);
  let sums = arr.reduce((acc, curr) => acc + curr);
  let sum = 0;

  for (let i = 0; i < arr.length; i++) {
    sums -= arr[i];
    sum += arr[i] * sums;
  }

  console.log(sum % 1000000007);
})(require("fs").readFileSync("/dev/stdin", "utf8"));