(* O(n) *)
let f () = Scanf.scanf " %d" @@ (+) 0
let n = f ()
let a_ss = Array.init 2 @@ fun _ -> Array.init n @@ fun _ -> f ()
let cs = [|ref 0; ref 0|]
let accs = Array.init 2 @@ fun _ -> Array.make (n + 1) 0
let ans = ref 0
let _ =
  for i = 0 to n - 1 do
    for j = 0 to 1 do
      cs.(j) := !(cs.(j)) + a_ss.(j).(i);
      accs.(j).(i + 1) <- !(cs.(j));
    done
  done;
  for i = 0 to n - 1 do
    ans := max !ans @@ accs.(0).(i + 1) - accs.(0).(0) + accs.(1).(n) - accs.(1).(i)
  done;
  Printf.printf "%d\n" !ans