import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuple (x : y : z : _) = (x, y, z)

main = do
    n <- getInt
    abcs <- V.fromList . map toTuple <$> replicateM n getIntList
    dp <- VM.replicate (n + 1) (0, 0, 0)
    forM_ [1..n] $ \i -> do
         (pa, pb, pc) <- VM.read dp (i - 1)
         let (na, nb, nc) = abcs V.! (i - 1)
         VM.write dp i $
             ( max (pb + na) (pc + na)
             , max (pc + nb) (pa + nb)
             , max (pa + nc) (pb + nc) )
    (ma, mb, mc) <- VM.read dp n
    print $ maximum [ma, mb, mc]