let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const len = +readLine();
  const arr = readLine()
    .split(" ")
    .map((n) => BigInt(n));
  const MOD = BigInt(1e9 + 7);
  let sum = arr.reduce((a, b) => a + b, BigInt(0));
  let result = BigInt(0);

  for (let i = 0; i < len; i++) {
    sum -= arr[i];
    result += arr[i] * sum;
    result %= MOD;
  }

  console.log(Number(result));
}
