// priority_queue is generally max heap to make it min heap use priority_queue<int,vector<int>,greater<int>> pq;"
#include <bits/stdc++.h>
#define int                 long long int
#define double              long double
#define get(a,n)            for(int i=0;i<n;i++){cin>>a[i];}
#define maxm(a)             int maxi=LLONG_MIN;int index;for(int i=0;i<n;i++){if(maxi<a[i]){maxi=a[i];index=i;}}
#define minm(a)             int mini=LLONG_MAX;int index;for(int i=0;i<n;i++){if(mini>a[i]){mini=a[i];index=i;}}
#define db(x)               cout<<"["<<x<<"]"<<endl;
#define vv                  vector
#define endl                "\n"
#define PI                  acos(-1)
#define half(a)             a%2?(a/2+1):a/2
#define array               int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define pb                push_back
#define all(a)              a.begin(),a.end()
#define mod                 1000000007
#define no                  "NO"
#define yes                 "YES"
using namespace std;
template <typename T>
void printvec(vector<T>& vec){
	for(int i=0;i<vec.size();i++) cout<<vec[i]<<" ";
	cout<<endl;
}
vector<bool> is_prime(100000+1, true);
void seive(int n)
{
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
}
//this function returns 0 indexing array if the required element
//is less than minimum it returns -1 and greater than max it returns n.
int special_binary(int *a,int n,int x)
{
    int l=0;int r=n-1;int m=0;int f=x;int c=0;
     while(l<=r)
     {
       if(f>a[n-1])
        return n;
       m=(l+r)/2;
       if(a[m]<=f)
       {
           c=m+1;
           l=m+1;
       }
       else
       {
           r=m-1;
       }
     }
     return c-1;
}
void show(int *a,int n)
{
    int size = n;
    for(int i=0;i<size;i++)
    {
            cout<<a[i]<<" ";
    }   
    cout<<endl;
}
int binary_search(int *a,int n,int e)
{
    int f,l,m;f=0;l=n-1;
    while(f<=l)
    {//returns index of that value.
        m=(f+l)/2;
        if(e==a[m])
            return(m);
        else if(e>a[m])
                f=m+1;
            else
                l=m-1;
    }
    return -1;
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second<b.second);
}
void solve()
{
    int n;
    cin>>n;
    int dp[n+1][3]={};
    int c[n+1][3];
    for(int i=1;i<=n;i++)
    {
        cin>>c[i][0]>>c[i][1]>>c[i][2];
    }
    // dp[1][0]=c[1][0];
    // dp[1][1]=c[1][1];
    // dp[1][2]=c[1][2];
    // for(int i=1;i<=n;i++)
    // {
    //     cout<<c[i][0]<<" "<<c[i][1]<<" "<<c[i][2]<<endl;
    // }
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+c[i][0],dp[i-1][2]+c[i][0]);
        dp[i][1]=max(dp[i-1][0]+c[i][1],dp[i-1][2]+c[i][1]);
        dp[i][2]=max(dp[i-1][1]+c[i][2],dp[i-1][0]+c[i][2]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    int t=1;
    //cin>>t;
    //seive(100000);
    while(t--)
    {
        solve();
        
    }
   

  
}

Measured memory_bytes: 8308