
function main(input) {
    input = input.trim().split('\n')
    let n = parseInt(input[0])
    let a = input[1].split(' ').map(BigInt)

    const mod = BigInt(10**9 + 7)
    let sum = a.reduce((a,b)=>a+b, BigInt(0))

//  console.log(Number(sum))

    let ans=BigInt(0)
    for(let i=0; i<n; i++) {
        sum -= a[i]
        ans += a[i] * sum
        ans %= mod
    }
    console.log(Number(ans))

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