[FONT=Consolas]const[/FONT][FONT=Consolas] fi=[/FONT][FONT=Consolas]'d:\pascal\[/FONT][FONT=Consolas]qhd[/FONT][FONT=Consolas]\bottles\[/FONT][FONT=Consolas]input[/FONT][FONT=Consolas].txt'[/FONT][FONT=Consolas];[/FONT][FONT=Consolas]var i,n:longint; f,a:array[0..100] of longint;
procedure input;
var f:text;
begin
assign(f,fi);
reset(f);
readln(f,n);
for i:=1 to n do read(f,a[i]);
close(f);
end;
function max(a,b:longint):longint;
begin
if a>b then exit(a) else exit(b);
end;
procedure qhd;
begin
f[1]:=a[1]; f[2]:=a[1]+a[2];
f[3]:=max(max(a[1]+a[2],a[2]+a[3]),a[1]+a[3]);
for i:=4 to n do
f[i]:=max(f[i-2]+a[i],f[i-3]+a[i-1]+a[i]);
end;
procedure rslt;
var t:longint;
begin
t := n;
while (t > 3) do
begin
if (f[t] = f[t - 1]) then
begin
t := t - 1;
end
else if (f[t] = f[t - 3] + a[t - 1] + a[t]) then
begin
write(a[t], ' ', a[t - 1], ' ');
t := t - 3;
end
else if (f[t] = f[t - 2] + a[t]) then
begin
write(a[t], ' ');
t := t - 2;
end;
end;
end;
begin
input;
qhd;
rslt;
readln; [/FONT][FONT=Consolas]end[/FONT][FONT=Consolas].[/FONT]