// Slower C++ solution:
#include <iostream>

#include <queue>

#include <string>

#include <map>

#include <stdio.h>

#include <iomanip>

#include <math.h>

#include <vector>

#include <stack>

#include <algorithm>

#include <string.h>

#include <set>

#include <cstdlib>

#include <iostream>

#include <bits/stdc++.h>

#define pii pair<int,int> 

#define ll long long int 

#define sl(n) scanf("%lld",&n)

#define s(n) scanf("%d",&n)

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

#define fo(i,n) for(int i=1;i<=n;++i)

#define fnm(n,m) for(ll i=n;i<m+1;++i)

#define pb push_back

#define pf printf

#define F first

#define S second

#define srt(v) sort(v.begin(),v.end());

#define srtc(v,cmp) sort(v.begin(),v.end(),cmp);

#define srta(v,n) sort(v,v+n);

const ll LL_INF=0x3f3f3f3f3f3f;

const ll MOD=1073741824;





using namespace std;





int T;

int d,arr[100005][5];

int dp[100005][5];



int gen(int i,int prev){ // swim:0, bugs:1, homework:2

    if(i == d)return 0;

    int &ret = dp[i][prev];

    if(~ret)return ret;

    ret = gen(i+1,(prev+1)%3)+arr[i][(prev+1)%3];

    ret = max( ret , gen(i+1,(prev+2)%3)+arr[i][(prev+2)%3]);

    if(!i)ret = max( ret , gen(i+1,(prev)%3)+arr[i][(prev)%3]);

    return ret;

}



int main(){

    // pf("\t\t\t***************************************************************************\n\n");

    // pf("\t\t\t***************************************************************************\n\n");

    // freopen("input.txt","r",stdin);

    // freopen("output.txt","w",stdout);

    memset(dp,-1,sizeof dp);

    s(d);

    f(i,d){

        s(arr[i][0]);

        s(arr[i][1]);

        s(arr[i][2]);

    }

    pf("%d\n",gen(0,0));



    return 0;

} 

// Faster C++ solution for the same problem (measured speedup: 2.9867491525221506x):
#include <iostream>



using namespace std;



int n;

int a[100001], b[100001], c[100001];

bool found[100001][3];

long long int dp[100001][3];



long long int m(long long int a, long long int b){

    return ((a > b) ? a : b);

}



long long int f(int now, int k){

    if (now == n){

        if (k == 0){

            return max(b[now], c[now]);

        } else if (k == 1){

            return max(a[now], c[now]);

        } else if (k == 2) {

            return max(b[now], c[now]);

        } else {

            return max(a[now], max(b[now], c[now]));

        }

    } else {

        if (found[now][k]){

            return dp[now][k];

        } else {

            if (k == 0){

                dp[now][k] = m(b[now] + f(now+1, 1), c[now] + f(now+1, 2));

            } else if (k == 1){

                dp[now][k] = m(a[now] + f(now+1, 0), c[now] + f(now+1, 2));

            } else if (k == 2){

                dp[now][k] = m(b[now] + f(now+1, 1), a[now] + f(now+1, 0));

            } else {

                dp[now][k] = m(a[now] + f(now+1, 0), m(b[now] + f(now+1, 1), c[now] + f(now+1, 2)));

            }

            found[now][k] = true;

            return dp[now][k];

        }

    }

}



int main(){

    cin >> n;

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

        cin >> a[i] >> b[i] >> c[i];

    }

    dp[1][0] = a[1];

    dp[1][1] = b[1];

    dp[1][2] = c[1];

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

        dp[i][0] = a[i] + m(dp[i-1][1], dp[i-1][2]);

        dp[i][1] = b[i] + m(dp[i-1][0], dp[i-1][2]);

        dp[i][2] = c[i] + m(dp[i-1][0], dp[i-1][1]);

    }

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

}