#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9 +7  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   // ai + aj = j-i
   // ai+i = j - aj
   int n ;
   cin >> n ;
   map < ll ,  ll > mp ;
   vector < int  > a(n) ;
   for( int i = 0 ; i < n ; i++) cin >> a[i] ;
   for( int i = 0 ; i < n ; i++) mp[a[i]+i+1]++;
   ll ans = 0 ;
   for( int i = 0 ; i < n ; i++){
        ans += mp[i+1-a[i]] ;
   }
   cout << ans ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
