# include <bits/stdc++.h>
# define int      long long
# pragma GCC optimize "-O3"

using namespace std; 
map <int, int> mp;
void solve(){
    int n = 0, m = 0;
    cin >> n;
    vector <int> v(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
        m += mp[ i - v[i] ];
        mp[ i + v[i] ]++;
    }
    cout << m;
}
int32_t main(){
    //speed;

    int T = 1;
    //cin >> T;
    while( T-- ){
         solve();
         cout<<'\n';
    }
    //time;
}
 