#include "bits/stdc++.h"

using namespace std;
using ll = long long int;

int main()
{
    int n;
    cin >> n;

    vector<ll> A(n);
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }

    unordered_map<ll, int> count;
    for (int i = 0; i < n; i++)
    {
        count[i - A[i]]++;
    }

    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += count[A[i] + i];
    }

    cout << ans << endl;
}