#include using namespace std; using i32 = int; using i64 = long long; using f64 = double; using p2 = pair; using el = tuple; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); _main(); } void _main() { i64 n; cin >> n; vector p(n); for (i64 i = 0; i < n; i++) { cin >> p[i]; p[i]--; } vector used(n, false); vector ans(n + 1, 0); for (i64 s = 0; s < n; s++) { if (used[s]) continue; i64 g = 0; i64 i = s; i64 cnt = 0; while (!used[i]) { g = gcd(g, abs(i - s)); used[i] = true; i = p[i]; cnt++; } for (i64 x = 1; x * x <= g; x++) { if (g % x == 0) { ans[x] += cnt - 1; if (g / x != x) ans[g / x] += cnt - 1; } } } for (i64 i = 1; i < n; i++) { cout << ans[i] << "\n"; } }