let memoize n f =
  let dp = Hashtbl.create n in
  let rec get x =
    try Hashtbl.find dp x with
    | Not_found ->
        let result = f get x in
        Hashtbl.add dp x result;
        result in
  get

let () = Scanf.scanf "%d\n" @@ fun n ->
  let abcs = Array.init n @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> [| a; b; c |] in
  let dp = memoize (3 * n) @@ fun dp -> function
    | (0, i) -> abcs.(0).(i)
    | (i, 0) -> abcs.(i).(0) + max (dp (i - 1, 1)) (dp (i - 1, 2))
    | (i, 1) -> abcs.(i).(1) + max (dp (i - 1, 2)) (dp (i - 1, 0))
    | (i, 2) -> abcs.(i).(2) + max (dp (i - 1, 0)) (dp (i - 1, 1)) in
  Printf.printf "%d\n" @@ max (dp (n - 1, 0)) @@ max (dp (n - 1, 1)) (dp (n - 1, 2))
