#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}

vector<lli> prefix_function(string s) {
    lli n = (lli)s.length();
    vector<lli> pi(n);
    for (lli i = 1; i < n; i++) {
        lli j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}


vector<lli> z_function(string s) {
    lli n = (lli) s.length();
    vector<lli> z(n);
    for (lli i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

/*
1.to give bezouts coef
2.for non negative integers
3.all solutions can be obtained by x0 - b/g and y0 + a/g
4.can be used for computing the multiplicative inverse. Co-efficient of a is
the multiplicative inverse.
*/
pair<lli,lli> bez_coef(lli a,lli b){
    lli s0=1,s1=0,t0=0,t1=1;
	lli r,q;
	
	if(a<b){
	    swap(a,b);
	    swap(s0,t0);
	    swap(s1,t1);
	}
	
	lli c1,c2;
	
	while(1){
	    r = a%b;
	    q = a/b;
	    a=b;
	    b=r;
	    if(r==0){
	        return mp(s1,t1);
	    }
	    c1=s0;
	    c2=s1;
	    s0=s1;
	    s1 = c1 - q*c2;
	    c1 = t0;
	    c2= t1;
	    t0=t1;
	    t1 = c1 - q*c2;
	}
}

/*
1. to return the phi(n).
2. sum of phi of all divisors of n is n.
3. can be used to find index such  that raised to it gives remainder 1.
*/
lli phi(lli n) {
    lli result = n;
    for (lli i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if (n > 1)
        result -= result / n;
    return result;
}

/*
1.to get the phi of all numbers from 1 to n
*/
vector<lli> phi_1_to_n(lli n) {
    vector<lli> phi(n + 1);
    phi[0] = 0;
    phi[1] = 1;
    for (lli i = 2; i <= n; i++)
        phi[i] = i;

    for (lli i = 2; i <= n; i++) {
        if (phi[i] == i) {
            for (lli j = i; j <= n; j += i)
                phi[j] -= phi[j] / i;
        }
    }
    return phi;
}


vector<char> is_prime_array(lli n){
    vector<char> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (lli i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (lli j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return is_prime;
}


int main() {
	anket;
	lli n;
	cin>>n;
	lli a[n];
	vector<lli> b,c;
	
	ask(i,0,n){
	    cin>>a[i];
	    b.pb(i+1+a[i]);
	    c.pb(i+1-a[i]);
	}
	
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	vector<lli>::iterator it1,it2;
	lli ans=0;
	ask(i,0,n){
	    if(b[i]>0){
	        it1 = lower_bound(c.begin(),c.end(), b[i]);
	        it2 = upper_bound(c.begin(),c.end(), b[i]);
	        //o3(b[i],*it1, *it2);
	        if(*it1<b[i]){
	            it1++;
	        }
	        if(it1<=it2){
	            ans += (it2 - it1);    
	        }
	        
	        //o1(ans);
	    }
	}
	o1(ans);
	return 0;
}




Measured memory_bytes: 8260