#include #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { cin.tie(nullptr) -> sync_with_stdio(false); int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; const int MAXA = 200000; const int MAX_SUM = 2*MAXA; const int B = 500; const int LIM = MAX_SUM/B; ll ans = 0; for (int m = 1; m <= B; ++m) { map cnt; rep(j, n) cnt[a[j]-m*(j+1)]++; rep(i, n) { auto it = cnt.find(a[i]-m*(i+1)); if (it != cnt.end()) { if (--(it->second) == 0) cnt.erase(it); } auto it2 = cnt.find(m*(i+1)-a[i]); if (it2 != cnt.end()) ans += it2->second; } } rep(i, n) { int maxj = min(n, LIM-i); if (maxj <= i) continue; for (int j = i+1; j <= maxj; ++j) { int s = i+j+2; int sum = a[i]+a[j]; if (sum%s == 0) { if (sum/s > B) ++ans; } } } cout << ans << "\n"; return 0; }