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

#include <string>

using namespace std;



int dx[] = {1 , -1 , 0 ,  0};

int dy[] = {0 ,  0 , 1 , -1};

#define ll long long

#define vi vector <int>

#define pi pair< int , int >

#define pl pair< ll , ll >

#define pii pair< pi , int >

#define fr first

#define sc second

#define pb push_back

#define FOR(i,a,b) for(int i=a;i<b;i++)

#define PI acos(-1)

#define eps 1e-6

#define OO   INT_MAX

#define infin LLONG_MAX

#define mod 1000000007

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

#define SZ(x) ((int)(sizeof(x)))

#define sz(v) (int)v.size()

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

#define frei freopen("in.in","r",stdin)

#define freo freopen("out.out","w",stdout)

#define SET(x,y)    x|=(1<<y)

#define CLEAR(x,y)  x&= ~(1<<y)

#define TOGGLE(x,y) x^=(1<<y)

#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define I(x) scanf("%d",&x)

#define I2(x,y) scanf("%d%d",&x,&y)

#define I3(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define I4(x,y,z,r) scanf("%d%d%d%d",&x,&y,&z,&r)

#define L(x) scanf("%I64d",&x)

#define L2(x,y) scanf("%I64d%I64d",&x,&y)

#define L3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)

#define L4(x,y,z,r) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&r);

#define D4(x,y,z,r) scanf("%lf%lf%lf%lf",&x,&y,&z,&r);

#define MAX (int)1e5+100

int n,k,a[MAX][3];

ll dp[MAX][4];

ll get(int i = 0,int state = 3)

{

    if(i > n)return -1e15;

    if(i == n)return 0;

    if(dp[i][state] + 1)return dp[i][state];

    ll ret = -1e15;

    if(state != 0)ret = max(ret,get(i+1,0) + a[i][0]);

    if(state != 1)ret = max(ret,get(i+1,1) + a[i][1]);

    if(state != 2)ret = max(ret,get(i+1,2) + a[i][2]);

    return dp[i][state] = ret;

}

int main()

{

    memset(dp,-1,SZ(dp));

    scanf("%d",&n);

    FOR(i,0,n)scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);

    printf("%I64d\n",get());

    return 0;

}


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

#include <string>

using namespace std;



int dx[] = {1 , -1 , 0 ,  0};

int dy[] = {0 ,  0 , 1 , -1};

#define ll long long

#define vi vector <int>

#define pi pair< int , int >

#define pl pair< ll , ll >

#define pii pair< pi , int >

#define fr first

#define sc second

#define pb push_back

#define FOR(i,a,b) for(int i=a;i<b;i++)

#define PI acos(-1)

#define eps 1e-6

#define OO   INT_MAX

#define infin LLONG_MAX

#define mod 1000000007

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

#define SZ(x) ((int)(sizeof(x)))

#define sz(v) (int)v.size()

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

#define frei freopen("in.in","r",stdin)

#define freo freopen("out.out","w",stdout)

#define SET(x,y)    x|=(1<<y)

#define CLEAR(x,y)  x&= ~(1<<y)

#define TOGGLE(x,y) x^=(1<<y)

#define READ(x,y)   ((bool)((ll)(x&(1<<y)) != 0))

#define I(x) scanf("%d",&x)

#define I2(x,y) scanf("%d%d",&x,&y)

#define I3(x,y,z) scanf("%d%d%d",&x,&y,&z)

#define I4(x,y,z,r) scanf("%d%d%d%d",&x,&y,&z,&r)

#define L(x) scanf("%I64d",&x)

#define L2(x,y) scanf("%I64d%I64d",&x,&y)

#define L3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)

#define L4(x,y,z,r) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&r);

#define D4(x,y,z,r) scanf("%lf%lf%lf%lf",&x,&y,&z,&r);

#define MAX (int)1e5+100

int n,k,a[MAX][3];

ll dp[2][4];

/*

ll get(int i = 0,int state = 3)

{

    if(i > n)return -1e15;

    if(i == n)return 0;

    if(dp[i][state] + 1)return dp[i][state];

    ll ret = -1e15;

    if(state != 0)ret = max(ret,get(i+1,0) + a[i][0]);

    if(state != 1)ret = max(ret,get(i+1,1) + a[i][1]);

    if(state != 2)ret = max(ret,get(i+1,2) + a[i][2]);

    return dp[i][state] = ret;

}

*/

int main()

{

    memset(dp,-1,SZ(dp));

    scanf("%d",&n);

    FOR(i,0,n)scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);

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

    for(int i = n-1 ; i >= 0 ; i--)

    {

        for(int state = 0 ; state <= 3 ; state ++)

        {

            ll ret = -1e15;

            if(state != 0)ret = max(ret,dp[1][0] + a[i][0]);

            if(state != 1)ret = max(ret,dp[1][1] + a[i][1]);

            if(state != 2)ret = max(ret,dp[1][2] + a[i][2]);

            dp[0][state] = ret;

        }

        for(int state = 0 ; state <= 3 ; state ++)

            dp[1][state] = dp[0][state];

    }

    printf("%I64d\n",dp[0][3]);

    return 0;

}