function main(arg) {
    
    let n = Number(arg.split("\n")[0])
    let a = arg.split("\n")[1].split(" ").map(Number)

    let mod = 10**9+7
    let sum = new Array(n+1)
    sum[0] = a[0]
    for(let i=0; i<n; i++) {
        sum[i+1] = (sum[i]+a[i]) % mod
    }
    //console.log(sum)

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

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