#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set Counter
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<int> v;
    ::std::unordered_map<T, int> Map;
    ::std::vector<::std::vector<int> > data;
    int kind;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_.size()){
        int sz = v_.size(); kind = 0;
        for(int i=0;i<sz;i++){
            T t = v_[i];
            if (Map.count(t)){
                data[Map[t]].push_back(i);
            }else{
                Map[t] = kind++;
                data.push_back(::std::vector<int>());
                data.back().push_back(i);
            }
            v[i] = Map[t];
        }
    }
    //query for all elements
    int query(T x){
        if (!Map.count(x)) return 0;
        return data[Map[x]].size();
    }
    //query for [a, b]
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!Map.count(x)) return 0;
        int xi = Map[x];
        auto right = ::std::upper_bound(data[xi].begin(),data[xi].end(),b);
        auto left  = ::std::lower_bound(data[xi].begin(),data[xi].end(),a);
        return right-left;
    }
    //search x for [k, tail]
    int find(int k, T x){
        if (!Map.count(x)) return -1;
        int xi = Map[x];
        auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
        if (itr!=data[xi].end()){
            return *itr;
        }else{
            return -1;
        }
    }
    //update for one point
    void update(int k, T x){
        int ei = v[k];
        auto eitr = ::std::lower_bound(data[ei].begin(),data[ei].end(),k);
        data[ei].erase(eitr);
        v[k] = Map[x];
        if (Map.count(x)){
            int xi = Map[x];
            auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
            data[xi].insert(itr, k);
        }else{
            Map[x] = kind++;
            data.push_back(::std::vector<int>());
            data.back().push_back(k);
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];
    vll A(n),B(n);
    rep(i,n) A[i]=a[i]+i;
    rep(i,n) B[i]=i-a[i];

    RangeSet<ll> rs(B);
    ll ans=0;
    rep(i,n){
        ans+=rs.query(i+1,n-1,A[i]);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 26580