Can you translate into the following code function?
program farkbul;
uses crt;
var
j,i,x,n,s1,s2,s3,largetotal,smalltotal,zerocontrol,result:integer;
a:array [1..100] of integer;
begin clrscr;
n:=3;
write('1.Enter the number');readln(a[1]);
for i:=2 to n do
begin
write(i,'.Enter the number');readln(a[i]);
for j:=1 to i do
begin
if a[i]<a[j] then begin x:=a[i]; a[i]:=a[j]; a[j]:=x; end;
end;
end;
clrscr;
writeln('--------------small to large-------------');
for i:=1 to n do
begin
writeln(' ',a[i]);
end;
s1:=a[1];
s2:=a[2];
s3:=a[3];
writeln('---------------large to small--------------');
writeln(' ',s3);
writeln(' ',s2);
writeln(' ',s1);
if s1=0 then begin
zerocontrol:=s2*100+s1*10+s3;
writeln(' ',zerocontrol);
end;
largetotal:=s1*100+s2*10+s3;
smalltotal:=s3*100+s2*10+s1;
writeln(' ',largetotal);
writeln(' ',smalltotal);
if s1=0 then sonuc:=smalltotal-zerocontrol
else result:=largetotal-smalltotal;
writeln('result: ',result);
readln;
end.