uses crt;
var a,s:array[1..1000000] of longint;
n,i,max,j,tg:longint;
BEGIN
clrscr;
readln(n);
for i:=1 to n do
begin
read(a[i]);
end;
max:=s[1];
for i:=2 to n-1 do
for j:=2 to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=2 to n do s[i]:=a[1]+a[i];
for i:=2 to n do if (i = 2) or (a[i-1] <> a[i]) then
begin
write(s[i],' ');
if s[i] > max then max:=s[i];
end;
writeln;
writeln('So lon nhat la ',max);
readln
END.