// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;



ll n;

std::vector<ll> ara[100010];

ll dp[100010][4];



ll fnc(ll idx,ll last){

  if(idx == n) return 0;

  if(dp[idx][last] != -1) return dp[idx][last];



  ll res1 = - (1<<25);

  ll res2 = - (1<<25);

  ll res3 = - (1<<25);



  if(last == 0){

    res1 = max(res1,ara[idx][0] + fnc(idx+1,1));

    res2 = max(res2,ara[idx][1] + fnc(idx+1,2));

    res3 = max(res3,ara[idx][2] + fnc(idx+1,3));

  }else if(last == 1){

    res2 = max(res2,ara[idx][1] + fnc(idx+1,2));

    res3 = max(res3,ara[idx][2] + fnc(idx+1,3));

  }else if(last == 2){

    res1 = max(res1,ara[idx][0] + fnc(idx+1,1));

    res3 = max(res3,ara[idx][2] + fnc(idx+1,3));

  }else if(last == 3){

    res1 = max(res1,ara[idx][0] + fnc(idx+1,1));

    res2 = max(res2,ara[idx][1] + fnc(idx+1,2));

  }

  dp[idx][last] = max(res1, max(res2,res3));

  return dp[idx][last];

}



int main(int argc, char const *argv[]) {

  memset(dp,-1,sizeof(dp));

  cin >> n;

  for(int i = 0;i<n;i++){

    int a,b,c;

    cin >> a >> b >> c;

    ara[i].push_back(a);

    ara[i].push_back(b);

    ara[i].push_back(c);

  }



  cout << fnc(0,0) << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.955545178826558x):
//                                 Alisher_2211

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        # include <bits/stdc++.h>

# define  long          long long

# define  all(vc)       vc.begin(),vc.end()

# define  allr(vc)      vc.rbegin(),vc.rend()

# define  pb            push_back

# define  fi            first 

# define  se            second

# define  pi            pair <long, long>    

# define  lcm(a, b)     (a * b) / __gcd(a, b)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        using namespace std;

const long N = 100100;

void read(){freopen("input.txt" , "r" , stdin );freopen("output.txt", "w" , stdout );}

long dp[N][3];

long n, k;

void solve(){

    cin >> n;

    long ar[n + 5][5];

    for (int i = 1; i <= n; ++i)

    {

        for (int j = 0; j < 3; ++j)

        {

            cin >> ar[i][j];

        }

    }

    for (int i = 1; i <= n; ++i)

    {

        for (int j = 0; j < 3; ++j)

        {

            if( !j ) 

                dp[i][0] = max( dp[i - 1][1], dp[i - 1][2] ) + ar[i][0];

            if( j == 1 ) 

                dp[i][1] = max( dp[i - 1][0], dp[i - 1][2] ) + ar[i][1];

            else 

                dp[i][2] = max( dp[i - 1][1], dp[i - 1][0] ) + ar[i][2];// <=

        }

    }

    cout << max({ dp[n][0], dp[n][1], dp[n][2] });

}

int32_t main(){

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 

        long T = 1;

        //cin >> T;

        while( T-- ){

            solve();

            cout<<'\n';

        }

cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";

}