const main = (input) => {
  input = input.trim().split('\n')
  const mod = 10n**9n + 7n
  const arr = input[1].split(' ').map(BigInt).sort((a, b) => a - b)

  let ans = 0n

  for (let i=0; i<arr.length-1; i++) {
    for (let e=i+1; e<arr.length; e++) {
      ans += arr[i] * arr[e] % mod
    }
  }

  return console.log(`${ans % mod}`)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))