//                                         Author :: Rubai Mandal
//                                                   ------------        
//                           Institution :: Jalpaiguri Government Engineerng College
//                                          ----------------------------------------

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define dd double
#define umap unordered_map<long long,long long>
#define smap map<string,ll>
#define mod 1000000007
#define vi std::vector<ll>
#define vs std::vector<string>
#define vc std::vector<char>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lvp vector<pair<ll,ll>>
#define dsort(a,n) sort(a,a+n,greater<int>())
#define srt(l) sort(l.begin(),l.end())
#define dsrt(p) sort(p.begin(), p.end(), greater<int>());
#define cunt(v,i) count(v.begin(), v.end(), i)
#define fr(i,a,n) for(ll i =a;i<n;i++)
#define rfr(i,n,a) for(ll i=n;i>=a;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tc(t) long long t;cin>>t;while(t--)
#define rr return(0);
#define fill(x,y) memset(x,y,sizeof(x))
#define pie 3.1415926535
#define inf 99999999999999999
#define rev(t) reverse(t.begin(),t.end())
string abc="abcdefghijklmnopqrstuvwxyz";

ll gcd(ll a,ll b){if (a == 0) return b; return gcd(b%a, a);}
ll fact(ll n) {ll res = 1; for (ll z = 2; z <= n; z++) res = res * z; return res; }
ll Pow(ll a, ll b) {ll res = 1;while (b){if (b & 1)res = res * a % mod;a = a * a % mod; b >>= 1;}return res;}
ll amax(ll a[],ll n) { ll max=a[0];fr(i,0,n){if(a[i]>max)max=a[i];}return max;}
ll amin(ll a[],ll n) { ll min=inf;fr(i,0,n){if(a[i]<min)min=a[i];}return min;}

void ip(ll a[],ll n)  {fr(i,0,n) cin>>a[i];}
void op(ll a[],ll n)  {fr(i,0,n){if(i==n-1)cout<<a[i]<<endl;else cout<<a[i]<<" ";}}

bool comp(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 

ll divisor(ll x)
{
    ll cnt=0;
    for(int i=1;i<=sqrt(x);i++)
    {
        if(x%i==0)
        {
            if(i!=x/i)cnt+=2;
            else cnt+=1;
        }
    }
    return cnt;
}
string d2b(int n) 
{ 
    string t="";
    ll key=0;
    // Size of an integer is assumed to be 32 bits 
    for (int i = 31; i >= 0; i--) { 
        int k = n >> i; 
        if (k & 1) 
        {
            t+='1';
            key=1;
        }
        else
        {
           if(key)
           t+='0';
        }
    }
    return t;
}
ll b2d(string n) 
{ 
    string num = n; 
    ll dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    ll base = 1; 
  
    ll len = num.length(); 
    for (ll i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
}

bool palindrome(ll le , ll ri , string s)
{
	if(ri-le <= 0) return true; 
	if(s[le] != s[ri])return false;
	return palindrome(le+1 , ri - 1 , s);
}
ll isprm(ll n) 
{
    if (n <= 1)  return 0; 
    if (n <= 3)  return 1; 
    if (n%2 == 0 || n%3 == 0) return 0; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return 0; 
    return 1;
    
}
ll lcm(ll a, ll b)
{
    return a /gcd(a, b) * b;
}
bool psqr(long double x) 
{    
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 


ll dp[100005][4];

ll fun(ll i,ll j,ll n,ll a[100005][4])
{
    if(i==n)
    return 0;
    if(dp[i][j]!=-1)
    return dp[i][j];
    else
    {
        ll maxi=-inf;
        if(j==0)
        {
            maxi=max(maxi,a[i][1]+fun(i+1,1,n,a));
            maxi=max(maxi,a[i][2]+fun(i+1,2,n,a));
            maxi=max(maxi,a[i][3]+fun(i+1,3,n,a));
        }
        else if(j==1)
        {
            maxi=max(maxi,a[i][2]+fun(i+1,2,n,a));
            maxi=max(maxi,a[i][3]+fun(i+1,3,n,a));
        }
        else if(j==2)
        {
            maxi=max(maxi,a[i][1]+fun(i+1,1,n,a));
            maxi=max(maxi,a[i][3]+fun(i+1,3,n,a));
        }
        else
        { 
            maxi=max(maxi,a[i][1]+fun(i+1,1,n,a));
            maxi=max(maxi,a[i][2]+fun(i+1,2,n,a));
            
        }
        return dp[i][j]=maxi;
    }
}

int main()

{
    fio
    ll n;
    cin>>n;
    ll a[n][4];
    fr(i,0,n)
    {
        fr(j,1,4)
        cin>>a[i][j];
    }
    fill (dp,-1);
    cout<<fun(0,0,n,a);
    rr
  
}

Measured memory_bytes: 19216