[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n =  read int
    let xss = Array.init n (fun _ -> reada int)

    let dp = Array.init n (fun _ -> Array.create 3 0)
    for i = 0 to 2 do dp.[0].[i] <- xss.[0].[i]
    for i = 1 to n - 1 do
        for j = 0 to 2 do
            seq {
                for k = 0 to 2 do
                if j <> k then yield dp.[i-1].[k] + xss.[i].[j]
            }
            |> Seq.max
            |> fun x -> dp.[i].[j] <- x

    printfn "%i" (Array.max dp.[n-1])
    0