#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <memory>
#include <vector>
#include <cmath>
#include <exception>

//! https://qiita.com/drken/items/dc53c683d6de8aeacf5a

using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline T in(){ T v; cin>> v; return v; }

class Date{
  public:
    Date(): day( 0), next( nullptr), previous( nullptr), act( INT64_MAX){
      happiness.resize( 3);
      dp.resize( 3);
    }
    ~Date(){
      //! 各Dateインスタンス毎のメモリ解放は不要
      //! Dateインスタンスが持つのは前後の参照のみのため
    }
    int64_t day;
    vector< int64_t> happiness;
    Date* next;
    Date* previous;
    int64_t makeNext( int64_t a, int64_t b, int64_t c, Date* n){
      if( next&& n) runtime_error( "ERROR on make Next");
      next= n;
      next->day= day+ 1;
      next->previous= self();
      next->happiness[ 0]= a;
      next->happiness[ 1]= b;
      next->happiness[ 2]= c;
      return day+ 1;
    }
    vector<int64_t> dp;
    int64_t act;
    Date* begin(){
      if( !previous) return self();
      if( previous->day) return next->begin();
      return self();
    }
    Date* end(){
      if( !next) return self();
      if( next->day) return next->end();
      return self();
    }
    Date* self(){ return this; }
    /*
    int64_t calculate(){
      //! 始端の場合はnextのcalculateを呼ぶ
      if( !previous) return next->calculate();
      //! 初日でないの場合
      for( int i= 0; i< 3; i++){
        if( previous->act== i) continue;
        if( chmax( dp, happiness[ i])) act= i;
      }
      return next? dp+ next->calculate(): dp;
    }
    */
};

class Vacation{
  public:
    Vacation( uint64_t length= 0xFFFF): date(), day( 0), length( length){
      // date.resize( 0xFFFF);
      date.resize( length+ 2);
    }
    ~Vacation(){
    }
    vector< Date> date;
    int64_t day;
    void push( int64_t a, int64_t b, int64_t c){
      auto end= date[ day].end();
      //auto end= &date[ day];
      day= end->makeNext( a, b, c, &date[ end->day+ 1]);
    }

    uint64_t length;

#if 0
    int64_t calculate(){ return date[ 0].begin()->calculate(); }
#else
    int64_t calculate(){
      //for( auto itr= date.begin(); itr!= date.end(); itr++){

      push( 0, 0, 0); // 回答出力用の空白
      for( int64_t h= 0; h<= length; h++){
        // cout<< "calculate: "<< itr- date.begin()<< endl;
        // if( !(itr- date.begin())) itr->dp= 0;
        //if( !(itr->previous)) continue;
        for( int i= 0; i< 3; i++){
          for( int j= 0; j< 3; j++){
            if( j== i) continue;
            chmax( date[ h+ 1].dp[j], date[ h].dp[i]+ date[ h].happiness[j]);
            // chmax( itr->dp[j],itr->previous->dp[i]+ itr->previous->happiness[j]);
          }
        }
        
      }
      int64_t dp= 0;
      for( int i= 0; i< 3; i++){
        chmax( dp, date[0].end()->dp[ i]);
      }
      return dp;
    }
#endif
};

int main(){
  const int64_t n= in<int64_t>();
  try{
    Vacation vacation( n);
    for( int64_t i= 0; i< n; i++){
      vacation.push( in<int>(), in<int>(), in<int>());
    }
    cout<< vacation.calculate()<< endl;
  } catch( const exception &e){
    clog<< e.what()<< endl;
    return -1;
  }
  return 0;
}



Measured memory_bytes: 14336