#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define mod 998244353
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
//#include<bits/stdc++.h>
bool sortbydesc(int a,int b){
	return a>b;
}
bool sortbydesc1(pair<int,int> a,pair<int,int> b){
	return a.first>b.first;
}
struct triple{
	int n1;

	int n2;
	int n3; 
};

class Graph 
{ 
	int V; 
	list<int> *adj; 
public: 
	Graph(int V); 
	void addEdge(int v, int w);
	void DFSUtil(int v, bool *visited,std::vector<int> &v1); 
}; 

Graph::Graph(int V) 
{ 
	this->V = V; 
	adj = new list<int>[V]; 
} 

void Graph::addEdge(int v, int w) 
{ 
	adj[v].push_back(w);}

void Graph::DFSUtil(int v, bool *visited,vector<int>&v1) 
{ 
	
	visited[v] = true;
	v1.push_back(v); 
	// cout << v << " "; 

	
	list<int>::iterator i; 
	for(i = adj[v].begin(); i != adj[v].end(); ++i) 
		if(!visited[*i]) 
			DFSUtil(*i, visited,v1); 
} 
// ll dp(ll n,ll k,ll *h,ll *a){
// 	if(n>=k){
// 		return 0;
// 	}
// 	else if(n==k-1){
// 		return a[k-1];
// 	}
// 	else if(n==k-2||n==k-3){
// 		return a[k-2];
// 	}
// 	else if(h[n]==-1){
// 		//return max(a[n]+)

// 	}
// }
bool  print1(int a[], int n, int ind) 
{ int k=1;
    // print from ind-th index to (n+i)th index. 
    for (int i = ind; i < n + ind; i++) {
    	if(a[i%n]==k){
    		k++;
    	}
    	else{
    		return 0;
    	}
       // cout << a[(i % n)] << " "; 
    }
    return 1;
}
bool  print2(int *a, int n, int ind) 
{ 
	int k=1;
    // print from ind-th index to (n+i)th index. 
    for (int i = ind; i<n+ ind; i++) {
    	if(a[i%n]==k){
    		k++;
    	}

    	else{
    		return 0;
    	}
        //cout << a[(i % n)] << " "; 
    }
    return 1;
}
int divCount(int n) 
{ 
    // sieve method for prime calculation 
    bool hash[n + 1]; 
    memset(hash, true, sizeof(hash)); 
    for (int p = 2; p * p < n; p++) 
        if (hash[p] == true) 
            for (int i = p * 2; i < n; i += p) 
                hash[i] = false; 
  
    // Traversing through all prime numbers 
    int total = 1; 
    for (int p = 2; p <= n; p++) { 
        if (hash[p]) { 
  
            // calculate number of divisor 
            // with formula total div =  
            // (p1+1) * (p2+1) *.....* (pn+1) 
            // where n = (a1^p1)*(a2^p2)....  
            // *(an^pn) ai being prime divisor 
            // for n and pi are their respective  
            // power in factorization 
            int count = 0; 
            if (n % p == 0) { 
                while (n % p == 0) { 
                    n = n / p; 
                    count++; 
                } 
                total = total * (count + 1); 
            } 
        } 
    } 
    return total; 
} 




int32_t main(){
	int n;
	cin>>n;
	int a[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	int dp[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			dp[i][j]=0;
		}
	}
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			if(j==0){
				dp[i][j]=max(dp[i-1][j+1],dp[i-1][j+2])+a[i][j];

			}
			else if(j==1){
				dp[i][j]=max(dp[i-1][j-1],dp[i-1][j+1])+a[i][j];

			}
			else{
				dp[i][j]=max(dp[i-1][j-1],dp[i-1][j-2])+a[i][j];

			}
		}
	}

cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;

	
	return 0;
}

Measured memory_bytes: 4992