#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> mp;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin >> x;
 
        ans += mp[i-x];
 
        mp[i+x]++;
    }
 
    cout << ans;
 
    return 0;
}
