#include<bits/stdc++.h>
using namespace std;

int count(int n,int d,int ct, vector<vector<int>> &dp, vector<int> &a, vector<int> &b, vector<int> &c)
{
    if(d==0)
    {
        ct=0;
        int p=dp[d][ct] = a[d] + count(n,d+1,ct,dp,a,b,c);
        ct=1;
        int q=dp[d][ct] = b[d] + count(n,d+1,ct,dp,a,b,c);
        ct=2;
        int r=dp[d][ct] = c[d] + count(n,d+1,ct,dp,a,b,c);
        return max({p,q,r});
    }
    else if(d==n-1)
    {
        if(ct==0)
        {
            int p,q;
            if(dp[d][ct+1]!=-1)
            p=dp[d][ct+1];
            else
            {
                dp[d][ct+1] = b[d];
                p=dp[d][ct+1];
                //cout<<"dp[d]["<<ct+1<<"]="<<dp[d][ct+1]<<"-"<<b[d]<<endl;
            }
            
            if(dp[d][ct+2]!=-1)
            q=dp[d][ct+2];
            else
            {
                dp[d][ct+2] = c[d];
                q=dp[d][ct+2];
                //cout<<"dp[d]["<<ct+2<<"]="<<dp[d][ct+2]<<"-"<<c[d]<<endl;
            }
            return max(p,q);
        }
        if(ct==1)
        {
            int p,q;
            if(dp[d][ct-1]!=-1)
            p=dp[d][ct-1];
            else
            {
                dp[d][ct-1] = a[d];
                p=dp[d][ct-1];
                //cout<<"dp[d]["<<ct-1<<"]="<<dp[d][ct-1]<<"-"<<a[d]<<endl;
            }
            
            if(dp[d][ct+1]!=-1)
            q=dp[d][ct+1];
            else
            {
                dp[d][ct+1] = c[d];
                q=dp[d][ct+1];
                //cout<<"dp[d]["<<ct+1<<"]="<<dp[d][ct+1]<<"-"<<c[d]<<endl;
            }
            return max(p,q);
        }
        if(ct==2)
        {
            int p,q;
            if(dp[d][ct-2]!=-1)
            p=dp[d][ct-2];
            else
            {
                dp[d][ct-2] = a[d];
                p=dp[d][ct-2];
                //cout<<"dp[d]["<<ct-2<<"]="<<dp[d][ct-2]<<"-"<<a[d]<<endl;
            }
            
            if(dp[d][ct-1]!=-1)
            q=dp[d][ct-1];
            else
            {
                dp[d][ct-1] = b[d];
                q=dp[d][ct-1];
                //cout<<"dp[d]["<<ct-1<<"]="<<dp[d][ct-1]<<"-"<<b[d]<<endl;
            }
            return max(p,q);
        }
    }
    
    else
    {
        if(ct==0)
        {
            int p,q;
            if(dp[d][ct+1]!=-1)
            p=dp[d][ct+1];
            else
            {
                dp[d][ct+1] = b[d] + count(n,d+1,ct+1,dp,a,b,c);
                p=dp[d][ct+1];
            }
            
            if(dp[d][ct+2]!=-1)
            q=dp[d][ct+2];
            else
            {
                dp[d][ct+2] = c[d] + count(n,d+1,ct+2,dp,a,b,c);
                q=dp[d][ct+2];
            }
            return max(p,q);
        }
        if(ct==1)
        {
            int p,q;
            if(dp[d][ct-1]!=-1)
            p=dp[d][ct-1];
            else
            {
                dp[d][ct-1] = a[d] + count(n,d+1,ct-1,dp,a,b,c);
                p=dp[d][ct-1];
            }
            
            if(dp[d][ct+1]!=-1)
            q=dp[d][ct+1];
            else
            {
                dp[d][ct+1] = c[d] + count(n,d+1,ct+1,dp,a,b,c);
                q=dp[d][ct+1];
            }
            return max(p,q);
        }
        if(ct==2)
        {
            int p,q;
            if(dp[d][ct-2]!=-1)
            p=dp[d][ct-2];
            else
            {
                dp[d][ct-2] = a[d] + count(n,d+1,ct-2,dp,a,b,c);
                p=dp[d][ct-2];
            }
            
            if(dp[d][ct-1]!=-1)
            q=dp[d][ct-1];
            else
            {
                dp[d][ct-1] = b[d] + count(n,d+1,ct-1,dp,a,b,c);
                q=dp[d][ct-1];
            }
            return max(p,q);
        }
    }
}
int main()
{
  int n;
  cin>>n;
  
  vector<vector<int> > dp( n , vector<int> (3, -1));  
  
  int i;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n);
  for(i=0;i<n;i++)
  {
     cin>>a[i];
     cin>>b[i];
     cin>>c[i];
  }
    
  int d=0;
  int ct=0;
  int res;
  if(n==1)
  {
      res=max({a[0],b[0],c[0]});
  }
  else
  res=count(n,d,ct,dp,a,b,c);
  cout<<res<<endl;
  
  /*for (int i = 0; i < n; i++) { 
        for (int j = 0; j < 3; j++){ 
            cout<< dp[i][j]<< " "; 
        } 
        cout<< "\n"; 
    }*/ 
  //cout<<c;
}

Measured memory_bytes: 17792