program first; type matrix = array[1..50,1..50] of integer; var a:matrix; i,j,n,min,k:integer; s,max:longint; function cols(count:integer; from:matrix; row,col:integer):longint; var j:integer; s:longint; begin s := 0; for j:=col to col+count-1 do s := s + from[row,j]; cols := s; end; function rows(count:integer; from:matrix; row,col:integer):longint; var i:integer; s:longint; begin s := 0; for i:=row+1 to row+count-2 do s := s + from[i,col]; rows := s; end; begin readln(n); for i:=1 to n do for j:=1 to n do read(a[i,j]); max := -25001; for i:=1 to n do for j:=1 to n do begin if n-i+1>n-j+1 then min := n-j+1 else min := n-i+1; for k:=1 to min do begin s := 0; if k = 1 then s := s + cols(k,a,i,j) else s := s + cols(k,a,i,j) + cols(k,a,i+k-1,j) + rows(k,a,i,j) + rows(k,a,i,j+k-1); if s>max then max := s; end; end; write(max); end.