
func main() {
    let N = Int(readLine()!)!
    
    let A = readLine()!.split(separator: " ").map { Int($0)! }

    var S = 0
    for i in 0...N-2 {
        var SubS = 0
        for j in i...N-1 {
            if i != j {
                SubS += A[j]
            }
        }
        S = (S + SubS * A[i]) % 1_000_000_007
    }
    
    print(S)
}

main()

