// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



typedef unsigned long long ull;

typedef long long ll;

typedef pair<int, int> ii;

typedef vector<ii> vii;

typedef vector<int> vi;

typedef vector<ll> vll;



#define PI (2*acos(0.0))

#define eps 1e-9

#define pb push_back

#define endl "\n"

#define watch(x) cout << (#x) << " is " << (x) << endl;

#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;

#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;

#define ff first

#define ss second

#define fu cout << "lol" << endl;

#define precision(n) cout << fixed << setprecision(n);

#define lb lower_bound

#define up upper_bound

#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}

#define all(a) a.begin(), a.end()

#define min3(a,b,c) min(a,min(b,c))

#define max3(a,b,c) max(a,max(b,c))

#define mem(a,val) memset(a,val,sizeof(a))

#define loop(i,n) for(i = 0; i < n; i++)

#define TC() ull T; cin>>T; while(T--)

#define IN(x) {scanf("%d",&x);}

#define LL(x) {scanf("%lld",&x);}

#define CC(x) {scanf("%c",&x);}

#define pfl(x) printf("%d\n",x)

#define pfll(x) printf("%lld\n",x)

#define newl puts("")

#define space printf(" ")

#define MOD 1000000007

#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);



const int N = 1e5 + 10;

int arr[N][3];

int dp[N][3];

int n;



int f(int id, int t){

    if(id >= n) return 0;

    if(t == -1){

        dp[id][0] = f(id+1,1) + arr[id][0];

        dp[id][1] = f(id+1,2) + arr[id][1];

        dp[id][2] = f(id+1,3) + arr[id][2];

        return max3(dp[id][0], dp[id][1], dp[id][2]);

    }

    if(dp[id][t] != -1) return dp[id][t];

    if(t == 1){

        dp[id][t] = f(id+1,2) + arr[id][1];

        dp[id][t] = max(dp[id][t], f(id+1,3) + arr[id][2]);

        return dp[id][t];

    }

    if(t == 2){

        dp[id][t] = f(id+1,1) + arr[id][0];

        dp[id][t] = max(dp[id][t], f(id+1,3) + arr[id][2]);

        return dp[id][t];

    }

    if(t == 3){

        dp[id][t] = f(id+1,2) + arr[id][1];

        dp[id][t] = max(dp[id][t], f(id+1,1) + arr[id][0]);

        return dp[id][t];

    }

}



int main()

{

    int i = 0, j = 0, cs = 0, in;

    cin>>n;

    for(i = 0; i < n; i++){

        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

    }

    mem(dp,-1);

    cout << f(0,-1) << endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 2.2040872690064397x):
#include<bits/stdc++.h>



using namespace std;



typedef unsigned long long ull;

typedef long long ll;

typedef pair<int, int> ii;

typedef vector<ii> vii;

typedef vector<int> vi;

typedef vector<ll> vll;



#define PI (2*acos(0.0))

#define eps 1e-9

#define pb push_back

#define endl "\n"

#define watch(x) cout << (#x) << " is " << (x) << endl;

#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;

#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;

#define ff first

#define ss second

#define fu cout << "lol" << endl;

#define precision(n) cout << fixed << setprecision(n);

#define lb lower_bound

#define up upper_bound

#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}

#define all(a) a.begin(), a.end()

#define min3(a,b,c) min(a,min(b,c))

#define max3(a,b,c) max(a,max(b,c))

#define mem(a,val) memset(a,val,sizeof(a))

#define loop(i,n) for(i = 0; i < n; i++)

#define TC() ull T; cin>>T; while(T--)

#define IN(x) {scanf("%d",&x);}

#define LL(x) {scanf("%lld",&x);}

#define CC(x) {scanf("%c",&x);}

#define pfl(x) printf("%d\n",x)

#define pfll(x) printf("%lld\n",x)

#define newl puts("")

#define space printf(" ")

#define MOD 1000000007

#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);



const int N = 1e5 + 100;

int arr[N][3];

int dp[N][3];



int main()

{

    int i = 0, j = 0, cs = 0, in;

    int n; cin>>n;

    for(i = 0; i < n; i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

    dp[0][0] = arr[0][0], dp[0][1] = arr[0][1], dp[0][2] = arr[0][2];

    for(i = 1; i < n; i++){

        dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);

        dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);

        dp[i][2] = arr[i][2] + max(dp[i-1][1], dp[i-1][0]);

    }

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

    return 0;

}