function mod(n, m) {
    return ((n % m) + m) % m;
}

const processData = (lines) => {
    const nums = lines[1].split(' ').map(x => +x)
    const limit = Math.pow(10, 9) + 7
    let sum = 0
    let totalSum = 0
    for (let i=0; i<nums.length; i++) {
        totalSum = totalSum + nums[i]
    }
    totalSum = totalSum % limit
    let localSum = totalSum
    for (let i=0; i<nums.length-1; i++) {
        localSum = mod(localSum - nums[i], limit)
        sum = (sum + ((nums[i] * localSum)%limit)) % limit
    }

    console.log(sum)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})
