var
a,b:array[1..100000]of longint;
n,i,j,k:longint;
begin
assign(input,'treat.in');
assign(output,'treat.out');
reset(input);
rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i]);
for i:=1 to n do
begin
for j:=1 to n do b[j]:=0;
j:=i;
b[j]:=1;
k:=1;
while b[a[j]]=0 do
begin
b[a[j]]:=1;
k:=k+1;
j:=a[j];
end;
writeln(k);
end;
close(input);
close(output);
end.