#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); std::cerr << std::fixed << std::setprecision(8); } }; IOSetup iosetup; using ll = int64_t; using int128_t = __int128; using uint128_t = unsigned __int128; template constexpr auto rep_iota_impl(T start, T stop) noexcept { return std::views::iota(start, (start < stop ? stop : start)); } template inline constexpr auto rep_impl(auto start, auto stop) noexcept { return rep_iota_impl(start, stop); } template inline void read(Ts&... ts) { (std::cin >> ... >> ts); } template std::vector VEC(int size) { std::vector res(size); for (T& x : res) std::cin >> x; return res; } template auto max(const Iterable& A) { if (A.empty()) { assert(false); } return *std::max_element(A.begin(), A.end()); } using std::vector; inline constexpr uint32_t pow_mod_uint32(auto base, int64_t exp, uint32_t mod) { assert(0 <= exp); assert(mod != 0); return pow_mod_constexpr(safe_mod_uint(base, mod), exp, mod); } inline uint64_t pow_mod_uint64(auto base, int64_t exp, uint64_t mod) { using uint128_t = unsigned __int128; assert(0 <= exp); assert(mod != 0); return pow_mod_constexpr(safe_mod_uint(base, mod), exp, mod); } template void put(const T& t) { std::cout << t; } template void print(const Ts&... ts) { put(ts...); std::cout << "\n"; } using std::cin; using std::cout; using std::map; using std::pair; using std::set; using std::string; using std::tuple; using std::vector; int main() { int64_t N; read(N); auto A = VEC(N); ll U = max(A); ll T = (ll)(pow(1.0 * U * U / N / 10, 1.0 / 3.0)) + 1; ll res = 0; for (const auto k : rep_impl(1, T + 1)) { std::unordered_map d; for (const auto i : rep_impl(1, N + 1)) { ll a = A[i - 1]; ll key = a - k * i; res += d[-(key)]; d[key] += 1; } } ll mx = (2 * U) / T; for (const auto i : rep_impl(1, N + 1)) { if (not(i <= mx)) break; ll a = A[i - 1]; for (const auto j : rep_impl(i + 1, N + 1)) { if (not(i + j <= mx)) break; if (not(i < j)) continue; ll b = A[j - 1]; if ((a + b) % (i + j) != 0) continue; ll k = (a + b) / (i + j); if (T + 1 <= k) res += 1; } } print(res); }