#include using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; #define rep(i,n) for(ll i=0;i T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); } template T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); } template inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; } template inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; } template ostream &operator<<(ostream &os, const vector &a){ if (a.empty()) return os; os << a.front(); for (auto e : a | views::drop(1)){ os << ' ' << e; } return os; } void dump(auto ...vs){ ((cout << vs << ' '), ...) << endl; } void solve() { ll N; cin>>N; vector P(N); rep(i,N)cin>>P[i]; rep(i,N)P[i]--; vector ans(N,0); vector used(N,false); rep(i,N){ if (used[i])continue; ll pi=i; ll g=0; ll cnt=0; while (!used[pi]){ used[pi]=true; cnt++; g=gcd(g,pi-P[pi]); pi=P[pi]; } if (g==0)continue; for (ll i=1;i<=g;i++){ if (i*i>g)break; if (i*i==g){ ans[i]+=cnt-1; break; } if (g%i==0){ ans[i]+=cnt-1; ans[g/i]+=cnt-1; } } } rep(i,N-1){ cout<sync_with_stdio(0); ll T=1; while (T--){ solve(); } return 0; }