uses crt;
var i,n,t,j,tong:longint;
a:array[1..1000000] of longint;
{-------------------------}
function nt(x:longint):boolean;
var h:longint;
begin
if x<2 then exit(false);
for h:=2 to trunc(sqrt(x)) do if x mod h=0 then exit(false);
exit(true);
end;
{-------------------------}
begin
clrscr;
readln(n);
for i:=1 to n do
begin
write('a[',i,']=');
readln(a[i]);
end;
write('a, ');
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
end;
for i:=1 to n do write(a[i],' ');
writeln;
for i:=1 to n do if (nt(a[i])) then tong:=tong+a[i];
write('b, ',tong);
readln
end.