-- C "Vacation"
-- -------------
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

-- ByteStringを用いた入力
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readIntPair3 :: BS.ByteString -> (Int, Int, Int)
readIntPair3 s = (a, b, c)
  where
    (a, s') = fromJust . BS.readInt $ s
    (b, s'') = fromJust . BS.readInt . BS.dropWhile isSpace $ s'
    (c, _) = fromJust . BS.readInt . BS.dropWhile isSpace $ s''

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntPair3 :: IO (Int, Int, Int)
getIntPair3 = readIntPair3 <$> BS.getLine
-- -------------

main = do
  n <- getInt
  xs <- VU.replicateM n getIntPair3
  let step (x, y, z) (a, b, c) = (a + y`max`z, b + x`max`z, c + x`max`y)
  print . (\(a, b, c) -> a `max` b `max` c) . VU.foldl' step (0, 0, 0) $ xs