#include<bits/stdc++.h>
#include<sstream>
#define ll long long int
#include <stdlib.h>
#include <vector>
#define pi acos(-1)
#define maxm 100005
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
///s1.substr(1,3);///STARTING FROM INDEX 1, 3 LNEGTH SUBSTRING.
///s1.find("adn")///RETURNS STARTING INDEX OF THE SUBSTRING
///"adn" IF IT EXISTS IN THE STRING S1.///
///s1.find("adn",int pos);///RETURNS STARTING INDEX OF THE
///SUBSTRING "adn" SEARCHING FROM INDEX POS OF STRING s1.///
///string::npos returns a garbage value if not found...
///reverse(s1.begin(),s1.end())-> to reverse a string.
///next_permutation(f,f+n)->f array er next permutation return korbe..
///str.erase(1,2)->deletes 2 char from index 1..
///for(auto i:p2)->i=p2.begin() theke p2.end() er ag porjonto..
///max_element(v,v+4);->return a pointer to the max element
///in a array/vector.. v from 1st element to 4th element.
///same for min_element(v,v+4);
///__builtin_popcount(a);->counts how many number of one's
/// in a in binary representation.
///accumulate(l1+1,l1+10+1,0LL)=>it perform the sum from l1[1] to
///l1[10] and 0 is the initial sum.
///cout<<fixed<<setprecision(12)<<x14<<endl;//=>x14 er
///doshomik er por 12 ta 0 thakbe.
///sort()=>[startaddress,endaddress).
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd(a,b)
using namespace std;

ll l1[200005],vis[200005],l3[1000005],s=0,m=0,mn=0;
ll dx[]={1,0,-1,0};
ll dy[]={0,-1,0,1};

char s2[maxm];
//int sum[max];
int tree[maxm*4];
//int prop[max*3];
void STB(int at,int L,int R)
{
    //int sum[at]=0;
    if(L==R){
        tree[at]=(s2[L-1]-'0');
        return;
    }
    int mid=(L+R)/2;
    STB(2*at,L,mid);
    STB(2*at+1,mid+1,R);
    //tree[at]=tree[2*at]+tree[2*at+1];
    //return sum[at];
}

void update(int at,int L,int R,int pos1,int pos2)
{
    if(L>pos2 || R<pos1)return;

    if(L>=pos1 && R<=pos2){
        tree[at]^=1;
        return;
    }
    int mid=(L+R)>>1;
//    if(pos2<=mid)update((at<<1)+1,L,mid,pos1,pos2);
//    else if(pos1>mid)update((at<<1)+2,mid+1,R,pos1,pos2);
//    else{
//        update((at<<1)+1,L,mid,pos1,mid);
//        update((at<<1)+2,mid+1,R,mid+1,pos2);
//    }
    update((at<<1),L,mid,pos1,pos2);
    update((at<<1)+1,mid+1,R,pos1,pos2);
    //tree[at]=tree[(at<<1)+1]+tree[(at<<1)+2]+prop[at]*(R-L+1);
}

int query(int at,int L,int R,int l)
{
    //if(L<=l && l<=R)return tree[at];
    if(L==R)return tree[at];
    if(L>l && l>R)return 0;

    int mid=(L+R)>>1;
//    if(l<=mid)query((at<<1)+1,L,mid,l,carry+prop[at]);
//    else query((at<<1)+2,mid+1,R,l,carry+prop[at]);
    if(l<=mid)return tree[at]^query((at<<1),L,mid,l);
    else return tree[at]^query((at<<1)+1,mid+1,R,l);
    //return ;
}

///reverse sorting function.
bool revp(const pair<ll,ll>&a,const pair<ll,ll>&b){
    if(a.first!=b.first)return a.first>b.first;
    else return a.second<b.second;
}
bool revp2(const pair<ll,ll>&a,const pair<ll,ll>&b){return a.second<b.second;}
bool revp3(const pair<ll,ll>&a,const pair<ll,ll>&b){return a.first>b.first;}

ll bigmod(ll b,ll p)
{
    ll an=1;b%=MOD;
    while(p>0){
        if(p&1)an=an*b%MOD;
        b=b*b%MOD;
        p>>=1;
    }
    return an;
    ///BINARY EXPONENTATION///
    ///TAKEN FROM "e-maxx"///
}

map<ll,ll>m4;

int main()///Hafiz///ICE 6th///
{
    //IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,i=1,j,k,y,n,c,m,z,z2,l,r,cases=0,d,p,nl,np,a,b,x2=-1,x1=1000000005,x3=0,x4=0,x5=0,x6=0,x7=0,x8=0;
    double x10=100000,x14,x15,x16,x17,x18;char x11,y1='a',y2,y3;int x12=0;
    string s3,s4,s5,s6,s7,s8;
    queue<ll>q2;
    stack<ll>st;
    set<ll>y4;
    vector<ll>vp;
    //vector<ll>vp2[200005];
    //map<ll,ll>mp;
    map<ll,ll>m2;
    map<ll,ll>::iterator it;
    map<ll,ll>m3;
    
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l1[i];
        m4[i+l1[i]]++;
        x3+=m4[i-l1[i]];
    }
    cout<<x3<<endl;
    
    return 0;
}


Measured memory_bytes: 27884