#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ctime>
#include<deque>
using namespace std;

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define vvi                vector<vector<int>>
#define mi                map<int,int>
#define pq                priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //for defining the precision of the decimal upto y places.
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)      type *a=new type[n];
#define test(t)           int t; cin>>t; while(t--)
#define no                cout<<"No\n";
#define yes               cout<<"Yes\n";
#define NO                cout<<"NO\n";
#define YES               cout<<"YES\n";
// #define for(i,n)          for(int i=0;i<n;i++)
// #define for(j,n)          for(int j=0;j<n;j++)
// #define forn(i,n)               for(int i=0;i<n;i--)



//**********************************************************************************************************
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

#define safemap               unordered_map<int,int,custom_hash>

//*********************************************************************************************************

void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}


int helper(int flag, int a[], int b[], int c[], int si, int n, vvi &dp)
{
//BASE CASE
  if (si == n)
    return 0;

  if (dp[si][flag] != -1 )
    return dp[si][flag];


//RECURSIVE CASE    //2-D DP State (flag,si)
  int x = INT_MIN;
  int y = INT_MIN;
  int z = INT_MIN;
  int ans = 0;

  if (flag != 1)
    x = a[si] + helper(1, a, b, c, si + 1, n, dp);

  if (flag != 2)
    y = b[si] + helper(2, a, b, c, si + 1, n, dp);

  if (flag != 3)
    z = c[si] + helper(3, a, b, c, si + 1, n, dp);

  ans = max(x, max(y, z));

  //cout << x << " " << y << " " << z << "\n";

  dp[si][flag] = ans;

  return ans;
}




int32_t main()
{

  io();
  clock_t begin = clock();

  int te = 1;

  // test(t)
  // {

  int n;
  cin >> n;

  int a[n] = {0};
  int b[n] = {0};
  int c[n] = {0};

  for (int i = 0; i < n; i++)
    cin >> a[i] >> b[i] >> c[i];


  vvi dp(n + 1, vi(4, -1));

  int p = helper(0, a, b, c, 0, n, dp);

  cout << dp[0][0] << "\n";


// cout << "Case #" << te << ": " << res << "\n";
//te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
  //}

  return 0;
}


Measured memory_bytes: 25112