process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!

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)
    sum[n-1] = a[n-1]
    for(let i=n-2; i>=0; i--) {
        //console.log(i)
        sum[i] = (sum[i+1]+a[i]) % mod
    }
    //console.log(sum)
    
    let ans=0
    for(let i=0; i<n-1; i++) {
        ans += (a[i]*sum[i+1])
        ans %= mod
    }
    console.log(ans)
}

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