Your "for" loop extends to the end of the program. So basically you get really wierd results.
begin
s:=0;
b:=0;
for i:=1 to n do
begin //------------------------------- here the loop begins
a[i]:=random(101);
s:=a[i]+s;
//------------------------------- looks like you've missed "end" here.
writeln('sum ',s);
writeln(s/n:0:2,' arithmetical ');
Now, what are you trying to do? The following lines look like they need another cycle:
//---------- start a new "for" cycle here
if a[i]<s/n then
b:=b+1;
//---------- and end it here
writeln('');
writeln(b,'numbers smallesr than arithmetical');
readln;
end;
end.
Try to follow the code. What it does first? What next? Imagine yourself a compiler and try to understand how it'll work and what it does.