import Foundation

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

for i in 1...N - 1{
  for e in i + 1...N{
    if(e - i == A[i - 1] + A[e - 1]){
      c += 1
    }
  }
}
print(c)