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

var r = 0
for (i, a) in As.enumerated() {
    for (j, b) in As.enumerated() {
        let x = (i - j).magnitude
        let y = a + b
        if x == y {
            r += 1
        }
    }
}

print(r/2)
