# include <bits/stdc++.h>
# define int      long long
# define all(vc)   vc.begin(),vc.end()
# define all2(vc)  vc.rbegin(),vc.rend()
# define pb        push_back
# define vec       vector
# define fi        first 
# pragma GCC optimize "-O3"
# define se        second
# define speed     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# define time      cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std; 
map <int, int> mp;
void solve(){
    int n = 0, m = 0;
    cin >> n;
    vec <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;
}
 