#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n+1); for(int i = 1; i <= n; i++) cin >> a[i]; unordered_map<int,int> cnt; long long ret = 0; for(int i = 1; i <= n; i++){ if(cnt.find(i-a[i]) != cnt.end()){ ret += cnt[i-a[i]]; } cnt[a[i] - i]++;; } cout << ret << endl; return 0; }