{-# LANGUAGE RecursiveDo        #-}
{-# LANGUAGE BangPatterns       #-}
{-# LANGUAGE OverloadedStrings  #-}
{-# LANGUAGE NumericUnderscores #-}

import Control.Monad
import Data.List
import Data.Char
import qualified Data.ByteString.Char8 as C8

spendOneDay :: [Int] -> [Int] -> [Int]
spendOneDay [a, b, c] [d, e, f] = [h, i, j]
  where h = d + max b c
        i = e + max a c
        j = f + max a b

main = do
  n <- readLn
  h <- replicateM n $ unfoldr (C8.readInt . C8.dropWhile isSpace) <$> C8.getLine
  print $ maximum $ foldl spendOneDay [0, 0, 0] h
