#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

    map<ll, int> m;
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        ans += m[i - a];
        m[i + a]++;
    }
    cout << ans << endl;
    return 0;
}