#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod=7+1e9;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
ll qpow(ll a,ll b,ll p){a%=p; ll ret=1;for(;b;b>>=1,a=a*a%p) if(b&1) ret=ret*a%p; return ret;}
ll getInv(ll x,ll p){return qpow(x,p-2,p);}

int main(){
    ll n; scanf("%d",&n);
    vector<ll> kkk(n+1);
    for(int i=1;i<=n;i++){
        scanf("%lld",&kkk[i]);
        }

    map<ll,int> hhh;

    for(int i=1;i<=n;i++){

        if(hhh[kkk[i]-i]) {
            hhh[kkk[i]-i]++;
        }

        else hhh[kkk[i]-i]=1;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(hhh[-kkk[i]-i]) {
            ans+=hhh[-kkk[i]-i];
            }
    }
    printf("%lld\n",ans);
}