import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main = do
    n<-readLn::IO Int
    xs<-replicateM n $ unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ f n xs
f n xs = maximum $ foldl' p [0,0,0] xs where
    p [u,v,w] [a,b,c] = [max (v+b) (w+c), max (u+a) (w+c), max (u+a) (v+b)]
