Okay so I have this program that generates 10 random number (1-1000), calculates their average and the amount of larger as well as smaller numbers than the average, this is what I have and for the life of me I can't figure out wheat I don't do right:

```
program random1;
var
i,sum,min_pl,max_pl:integer;
pin:array[1..10] of integer;
mo:array[1..10] of real;
begin
randomize;
for i:=1 to 10 do
pin[i]:=random(1000);
for i:=1 to 10 do
writeln(pin[i]);
sum:=0;
for i:=1 to 10 do
begin
sum:=sum+pin[i];
mo[i]:=sum/10;
end;
writeln();
writeln('The average is: ',mo[i]:4:2);
writeln();
min_pl:=0;
max_pl:=0;
for i:=1 to 10 do
if (mo[i]<pin[i]) then
min_pl:=min_pl+1
else if (mo[i]>pin[i]) then
max_pl:=max_pl+1;
writeln('The amount of numbers smaller than the average is: ',min_pl);
writeln('The amount of numbers larger than the average is: ',max_pl);
end.
```