#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n;
ll a[MAX];
map<ll, ll> mp;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        read(a[i]);
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += mp[a[i]-i];
        mp[-a[i]-i]++;
    }
    cout << ans << endl;

    return 0;
}