program dyskol(input,output);
 type list = 1..1000000;
 var N, i, j, max : list; sum : array[1..10000,1..10000] of integer;
Begin
 readln(N);
 i := 0;
 while not eoln do
 begin
  i := i + 1;
  read(a[i])
 end;
 readln;
 max := 0;
 for i := 1 to N-1 do
  for j := i + 1 to N do
   sum[i,j] := 0;
 for i := 1 to N-1 do
  for j := i + 1 to N do
  begin
   sum[i,j] := sum[i,j] + a[i] + a[j];
   if max < sum[i,j] then max := sum[i,j]
  end;
 writeln(max)
End. 