fillchar(bz,sizeof(bz),true);
for i:=1 to maxn do phi[i]:=i;
for i:=2 to maxn do
begin
if bz[i] then
begin
phi[i]:=i-1;
inc(ss[0]);
ss[ss[0]]:=i;
end;
for j:=1 to ss[0] do
begin
if maxn/ss[j]<i then break;
bz[i*ss[j]]:=false;
phi[i*ss[j]]:=phi[i]*(ss[j]-1);
if i mod ss[j]=0 then
begin
phi[i*ss[j]]:=phi[i]*ss[j];
break;
end;
end;
end;