program shuta;
const
maxline=80;
var
line:integer;
a:array[1..maxline,1..maxline] of integer;
b:array[1..maxline] of integer;
function maxsum(i,j:integer):integer;
begin
if i=line then
maxsum:=a[i,j]
else if maxsum(i+1,j)>maxsum(i+1,j+1)
then maxsum:=maxsum(i+1,j)+a[i,j]
else maxsum:=maxsum(i+1,j+1)+a[i,j];
b[i]:=a[i,j];
end;
procedure ini;
var
i,j:integer;
begin
assign(input,'shuta.in');
reset(input);
assign(output,'shuta.out');
rewrite(output);
readln(line);
for i:=1 to line do
begin
for j:=1 to i do
read(a[i,j]);
readln;
end;
close(input);
end;
procedure main;
var
i,j:integer;
begin
b[1]:=a[1,1];
writeln(maxsum(1,1));
end;
procedure print;
var
i:integer;
begin
for i:=1 to line do write(b[i],' ');
close(output);
end;
begin
ini;
main;
print;
end.