#include<bits/stdc++.h>
using namespace std;
#define ll long long int
typedef unsigned long long int ull;
typedef long double ldb;
#define B 1000000007
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repi(i,a,b) for(ll i=b-1;i>=a;i--)
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long int>
#define pb push_back
#define mp make_pair
#define sz size()
#define deci(n) fixed << setprecision(n)
#define INF 1e18
#define ani ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define M 1001
const int maxn = 2e5 + 42;
#define endl "\n"

 
void pairsort(ll a[], ll b[], ll n) 
{ 
    pair<ll, ll> pairt[n]; 
  
 
    for (ll i = 0; i < n; i++)  
    { 
        pairt[i].first = a[i]; 
        pairt[i].second = b[i]; 
    } 
  
    sort(pairt, pairt + n); 
      
    for (ll i = 0; i < n; i++)  
    { 
        a[i] = pairt[i].first; 
        b[i] = pairt[i].second; 
    } 
}
 
ll extendedGcd(ll a, ll b, ll & x, ll & y) {
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    ll x1, y1;
    ll d = extendedGcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}


  ll binaryToDecimal(string n) 
{ 
    string num = n; 
    ll dec_value = 0; 
    // Initializing base value to 1, i.e 2^0 
    ll base = 1;  
    ll len = num.length(); 
    for (ll i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
    return dec_value; 
} 


ll nCr(ll n,ll k){ 
    ll C[n + 1][k + 1]; 
    ll i, j; 
    for (i=0;i<=n;i++){ 
        for(j=0;j<=min(i,k);j++){
            if(j==0||j==i) 
                C[i][j]=1;  
            else
                C[i][j]=(C[i-1][j-1]%B+C[i-1][j]%B)%B; 
        } 
    }
    return C[n][k]%B; 
} 


ll countDivisors(ll n) 
{ 
    ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) 
    { 
        if (n % i == 0) 
        { 
            // If divisors are equal, 
            // count only one 
            if (n / i == i) 
                cnt++; 
  
            else // Otherwise count both 
                cnt = cnt + 2; 
        } 
    } 
    return cnt; 
}

/*
void dfs(int p,vector<int> a[],int v[])
{
    if(v[p])
        return ;
    v[p]=1;
    for(int i=0;i<a[p].size();i++)
    {
        if(!v[a[p][i]])
        dfs(a[p][i],a,v);
    }
} 

int v[M][M];
char a[M][M];
int cx[]={0,0,-1,1};
int cy[]={1,-1,0,0};
int dfs(int x,int y,int n)
{
    if(v[x][y])
        return 0;
    v[x][y]=1;
    int count=0;
    for(int i=0;i<4;i++)
    {
        int dx=x+cx[i];
        int dy=y+cy[i];
        if(dx>=0 && dx<n && dy>=0 && dy<n && a[x][y]=='1')
            count+=dfs(dx,dy,n);
    }

return count;
}

int solve(int n,char cake[N][N])
{
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            a[i][j]=cake[i][j];

    int maxi=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            if(a[i][j]=='1' && v[i][j]==0)
                maxi=max(maxi,dfs(i,j,n));
        
    return maxi;
}*/

int main()
{ 
ani;
    
   ll t=1; 
   // cin>>t;
     while(t--)
      {   
        
          ll n; cin>>n; ll a[n+1];  rep(i,1,n+1)cin>>a[i];     
          map<ll,ll> m;
          ll ans=0;
          for(int i=n;i>=1;i--)
          {
            ans+=m[i+a[i]];
            m[i-a[i]]++;
          }
cout<<ans;














      }
       
    





return 0;
}

Measured memory_bytes: 27876