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

    var count = 0
    for i in 0..<N {
        for j in 0..<N {
            let Ai = A[i]
            let Aj = A[j]
            if abs(i - j) == abs(Ai + Aj) {
                count += 1
            }
        }
    }
    print(count / 2)
    
}

main()