func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func mainC() {
    let N = readInt()
    let A = readInts()

    var sums: [Int] = []
    sums.append(0)

    for i in 0..<N-1 {
        sums.insert((sums.first! + A[N - 1 - i]) % (1000_000_000 + 7), at: 0)
    }

    var result = 0
    for i in 0..<(N-1) {
        result += A[i] * sums[i]
        result = result % (1000_000_000 + 7)
    }

    print(result % (1000_000_000 + 7))
}
mainC()