/*This code is written by Mayank Padia
	¨ ¨ ¨ ¨ ¨ ¨ ¨▲.︵.▲
¨ ¨ ¨ ¨ ¨ ¨ ¨◄ƒ░░ 0 }…..︵.
¨ ¨ ¨ ¨ ¨ ¨◄ƒ░░░░░░ o”)
¨ ¨ ¨ ¨ ¨ ◄ƒ░░░(────.·^”’
¨ ¨ ¨ ¨ ¨ ◄ƒ░░░§ ´
)\¨ ¨ ¨ ¨ ◄ƒ░░░░§ ¨ ¨ ¨✺✺✺
) \ ¨ ¨ ¨◄ƒ░░░░░§¨ ¨ ¨\|//✺
);;\ ¨ ¨ ◄ƒ░.︵.░░░§__(((
);;;\¨ ¨◄ƒ░(░░)\______//
);;;;\¨◄ƒ░░░░░░__//
);;;;;\◄ƒ░░░░░░░░§
);;;;;;;\░░░░░░░░░(((

 ---------------
|               |
|FRAGILE!       |
|               |
|HANDLE WITH    |
|          CARE!|
|   (^|^)       |
 --------------- 

*/

#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
#define vll vector<ll>
#define vvll vector< vll >
#define vld vector< ld >
#define vvld vector< vld >
#define pll pair<ll ,ll >
#define vllp vector< pll >
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define endl "\n"
#define test ll t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define F first
#define S second

#define forn(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define for1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define forr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define forab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))
#define MAX 1000000007
using namespace std;

/*
void dfs (ll x)
{
	a[x]=1;
	for (int i = 0; i < v[x].size(); ++i)
	{
		if(a[v[x][i]]==0)
			dfs(v[x][i]);
	}
}
void bfs(int u) 
{ 
    queue<int> q; 
  
    q.push(u); 
    v[u] = true; 
  
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  
        cout << f << " "; 
  
        // Enqueue all adjacent of f and mark them visited  
        for (auto i = g[f].begin(); i != g[f].end(); i++) { 
            if (!v[*i]) { 
                q.push(*i); 
                v[*i] = true; 
            } 
        } 
    } 
} 
*/


vll sieve;
void Sieve(int N){
	const ll maxn = N;
	sieve.resize(maxn);
	forn(i,maxn) sieve[i] = i;
	sieve[1] = -1;
	sieve[0] = -1;
	forab(i,2,maxn,1) if(i == sieve[i]) for(ll j = 2*i ; j < maxn ; j+=i) if(sieve[j] == j) sieve[j] = i;
}
ll extended_GCD(ll a , ll b , ll &x , ll &y){
	if(a == 0){
		x = 0;
		y = 1;
		return b;
	}
	ll x1 , y1;
	ll gcd = extended_GCD(b%a , a , x1 , y1);
	x = y1 - (b/a)*x1; 
	y = x1;
	return gcd;
}
ll power(ll a, ll b, ll m = MOD) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinv(ll a , ll mod = MOD){
	ll x , y;
	extended_GCD(a , mod , x , y);
	if(x < 0) x += mod;
	return x;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////
ll a[100009][3];
ll b[100009][3];
ll q1,q2,q3;
void dpp(ll c,ll n)
{
	if(c>=n)
		return;
	b[c][0]=max(b[c-1][1],b[c-1][2])+a[c][0];

	b[c][1]=max(b[c-1][0],b[c-1][2])+a[c][1];
	
	b[c][2]=max(b[c-1][1],b[c-1][0])+a[c][2];
	dpp(c+1,n);
}
void solve(){
	ll n;
    cin>>n;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    b[0][0]=a[0][0];
    b[0][1]=a[0][1];
    b[0][2]=a[0][2];
    dpp(1,n);
	cout<<max({b[n-1][0],b[n-1][1],b[n-1][2]})<<endl;
	}
int main(){
    ios::sync_with_stdio(0); cin.tie(0);
	solve();


return 0;
}

Measured memory_bytes: 4992