(* O(n) *)
let n = Scanf.scanf " %d" @@ (+) 0
let abcs = Array.init n @@ fun _ -> Scanf.scanf " %d %d %d" @@ fun a b c -> [|a; b; c|]
let dp = Array.make_matrix n 3 0
let _ =
  for i = 0 to 2 do dp.(0).(i) <- abcs.(0).(i) done;
  for i = 1 to n - 1 do
    for j = 0 to 2 do
      for k = 0 to 2 do
        if j <> k then dp.(i).(j) <- max dp.(i).(j) @@ dp.(i - 1).(k) + abcs.(i).(j) done done done;
  Array.fold_left max 0 dp.(n - 1) |> Printf.printf "%d\n"