let N = Int(readLine()!)!
let AN = readLine()!.split(separator: " ").compactMap { Int($0) }
let mod = 1000000007

var sumList: [Int] = []
for i in 0..<N-1 {
    let element = ((sumList.last ?? 0) + AN[N-i-1]) % mod
    sumList.append(element)
}

var result = 0
for i in 0..<N-1 {
    result += AN[i] * sumList[N-i-2]
    result %= mod
}
print(result)
