why WA Orz......PLZ help me`
var
n,i,j,k,x:longint;
f:array[1..10000,0..100]of longint;
ff:array[1..10000]of boolean;
begin
readln(n);
fillchar(f,sizeof(f),0);
for i:=2 to n do
begin
readln(x);
inc(f[i,0]); inc(f[x,0]);
f[i,f[i,0]]:=x; f[x,f[x,0]]:=i;
end;
fillchar(ff,sizeof(ff),true);
while n>2 do
begin
for i:=1 to n do
if f[i,0]=1 then
begin
dec(f[i,0]);
ff[i]:=false;
dec(f[f[i,1],0]);
for j:=1 to f[f[i,1],0] do
if f[f[i,1],j]=i then
begin
for k:=j to f[f[i,1],0] do
f[f[i,1],k]:=f[f[i,1],k+1];
break;
end;
dec(n);
end;
end;
if n=1 then
for i:=1 to n do
if ff[i] then writeln(i);
if n=2 then
begin
for i:=1 to n do
if ff[i] then
begin
write(i,' ');
break;
end;
for i:=i+1 to n do
if ff[i] then
writeln(i);
end;
end.