#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n); for(auto &&v : a) cin >> v; auto b = a.begin() - 1; ll ans = 0; for(int d = 1; d <= n; d++){ int m = min(n, (n / d) * 3); unordered_map mp; for(int i = 1; i <= m; i++){ int lv = b[i] - i * d; ans += mp[-lv]; mp[lv]++; } } cout << ans << '\n'; }