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

using namespace std;

 

#define ff              first

#define ss              second

#define int             long long

#define pb              push_back

#define mp              make_pair

#define pii             pair<int, int>

#define vi              vector<int>

#define si              set<int>

#define usi             unordered_set<int>

#define mii             map<int, int>

#define umii            unordered_map<int, int>

#define pqb             priority_queue<int>

#define pqs             priority_queue<int, vi, greater<int> >

#define setbits(x)      __builtin_popcountll(x)

#define zrobits(x)      __builtin_ctzll(x)

#define mod             1000000007

#define inf             1e18

#define endl            '\n'

#define ps(x,y)         fixed<<setprecision(y)<<x

#define mk(arr,n,type)  type *arr=new type[n];

#define w(t)            int t; cin>>t; while(t--)

mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

 

void jaiswal_sahil()

{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// #ifndef ONLINE_JUDGE

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

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

// #endif

}



const int N = 1e5 + 5;

int dp[N][3];

int n;

int maxPoint(int i, int a[N][3], int p){



    if(i == n)

        return 0;



    if(dp[i][p] != -1)

        return dp[i][p];

    

    int q1 = -inf, q2 = -inf, q3 = -inf;

    if(p==1){

        q2 = a[i][1] + maxPoint(i+1, a, 2);

        q3 = a[i][2] + maxPoint(i+1, a, 3);

    }else if(p==2){

        q1 = a[i][0] + maxPoint(i+1, a, 1);

        q3 = a[i][2] + maxPoint(i+1, a, 3);

    }else if(p==3){

        q1 = a[i][0] + maxPoint(i+1, a, 1);

        q2 = a[i][1] + maxPoint(i+1, a, 2);

    }



    return dp[i][p] = max({q1, q2, q3});

}

 

int32_t main()

{

    jaiswal_sahil();

    

    cin>>n;



    int a[N][3];

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

        int x, y, z; cin>>x>>y>>z;

        a[i][0] = x, a[i][1] = y, a[i][2] = z;

    }



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

    int x = a[0][0] + maxPoint(1, a, 1);

    int y = a[0][1] +  maxPoint(1, a, 2);

    int z = a[0][2] +  maxPoint(1, a, 3);

    int ans = max({x, y, z});



    cout<<ans<<endl;

    return 0;



}

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

using namespace std;

 

#define int             long long

#define ld              long double

#define ff              first

#define ss              second

#define pb              push_back

#define mp              make_pair

#define pii             pair<int, int>

#define mk(arr,n,type)  type *arr=new type[n];

#define vi              vector<int>

#define si              set<int>

#define usi             unordered_set<int>

#define mii             map<int, int>

#define umii            unordered_map<int, int>

#define pqmax           priority_queue<int>

#define pqmin           priority_queue<int, vi, greater<int> >

#define setbits(x)      __builtin_popcountll(x)

#define trailzrobits(x) __builtin_ctzll(x)

#define leadzrobits(x)  __builtin_clzll(x)

#define paritybits(x)   __builtin_parityll(x)

#define gcd             __gcd

#define lcm(x, y)       (x * y) / gcd(x, y)

#define mod             1000000007

#define endl            '\n'

#define PI              3.14159265358979323846

#define inf             1e18

#define sp(x,y)         fixed<<setprecision(y)<<x



void __print(int x) {cout<<x;}

void __print(float x){cout<<x;}

void __print(double x){cout<<x;}

void __print(ld x) {cout<<x;}

void __print(char x){cout <<'\''<<x<<'\'';}

void __print(const char *x){cout <<'\"' <<x<<'\"';}

void __print(const string &x) {cout<<'\"'<<x<<'\"';}

void __print(bool x) {cout<<(x?"true":"false");}

template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}

template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}

template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}

#ifndef ONLINE_JUDGE

#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)

#else 

#define dbg(x...)

#endif



int power(int x, int y, int p = mod){

    int res = 1;

    x %= p;

    while(y > 0){

        if(y & 1)

            res = (res * x) % p;

        y = y >> 1;

        x = (x * x) % p;

    }

    return res; 

}



int inv(int x, int p = mod){

    return power(x, p - 2) % p;

}



const int N = 1e6 + 6;



struct quantity{

    int a, b, c;

};

 

int32_t main(){



    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    

    int t = 1;

    // cin >> t;

    while(t--){

       

        int n; cin>>n;

        mk(arr, n+1, quantity);

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

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



        int dp[n+1][3];

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

        dp[1][1] = arr[1].b;

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



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

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

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

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

        }



        int ans = max({dp[n][0], dp[n][1], dp[n][2]});

        cout<<ans;

    }



    return 0;



}