(async () => {
    let input = '';
    for await (const chunk of process.stdin) input += chunk;
    let values = input.split(/\s/).map(v => +v);
    
    const length = values.shift();
    values = values.slice(0, length);

    let sum = 0;
    let tmp = 0;
    for (let i = length - 2; i >= 0; i--) {
        tmp += values[i + 1];
        sum = (sum + values[i] * tmp) % (1e9 + 7);
    }

    console.log(sum % (1e9 + 7));

})();
