import Control.Applicative
import Control.Monad
import Data.Array

main = do
	n <- readLn
	ls <- map (map read.words) <$> replicateM n getLine
	putStrLn.show $ maximum (dp ls)

dp (l:ls) = foldl happy l ls
happy [a,b,c] [va,vb,vc] = [va+max b c,vb+max a c,vc+max b a]