import sys from math import gcd def main(): sys.setrecursionlimit(1_000_000) input = sys.stdin.readline N = int(input().strip()) P = [0] + list(map(int, input().split())) visited = [False] * (N + 1) # F[g] = sum of (L-1) over cycles whose gcd-diff is g F = [0] * (N) # indices 0..N-1 (g is in 1..N-1) for i in range(1, N + 1): if visited[i]: continue # traverse cycle of permutation i -> P[i] cur = i pos = [] while not visited[cur]: visited[cur] = True pos.append(cur) cur = P[cur] L = len(pos) if L <= 1: continue base = pos[0] g = 0 for x in pos[1:]: g = gcd(g, abs(x - base)) # g is in 1..N-1 F[g] += (L - 1) ans = [0] * (N) for k in range(1, N): s = 0 for m in range(k, N, k): s += F[m] ans[k] = s out = "\n".join(str(ans[k]) for k in range(1, N)) print(out) if __name__ == "__main__": main()