let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d %d %d" (fun x y z -> [|x; y; z|])) in
  let dp = Array.init 3 (fun _ -> Array.make (n+1) 0) in
  for i = 1 to n do
    for d = 0 to 2 do
      dp.(d mod 3).(i) <-
        a.(i-1).(d) + max dp.((d+1) mod 3).(i-1) dp.((d+2) mod 3).(i-1)
    done;
  done;
  Printf.printf "%d\n" (dp.(0).(n) |> max dp.(1).(n) |> max dp.(2).(n))
  