// Slower C++ solution:
// Created by Kshitij Anand NSIT

#include <bits/stdc++.h>





using namespace std;





#define int long long

#define pb push_back

#define P pair<int,int>

#define F first

#define S second

#define vi vector<int>

#define vc vector<char>

#define vb vector<bool>

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

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

#define mp(a, b) make_pair(a, b)

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

#define min4(a, b, c, d) min(min(a, b), min(c, d))

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

#define max4(a, b, c, d) max(max(a, b), max(c, d))

#define fill(arr,val) memset(arr,val,sizeof(arr))

#define db(x)  cout<<#x<<" : "<<x<<endl





const int N = 1000000007;



int dp[100000][3];



int func(int arr[][3] , int n , int prev , int curr){



	if(curr == n) return 0;



	if(prev!=-1 && dp[curr][prev] != -1)  return dp[curr][prev];



	int ans =0;



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



		if(i!= prev)

			ans = max( arr[curr][i] + func(arr , n , i , curr+1) , ans);

	}



	dp[curr][prev] = ans;



	return ans;

}



void solve(){



    int n,a,b,c, ans=0, count=0, sum=0;

    cin>>n;

    int arr[n][3];

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



    	for(int j=0; j<3; j++) {

			cin>>arr[i][j];

    	}

    }



    fill(dp , -1);



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



    // 	for(int j=0; j<3; j++) {

    // 		dp[i][j] = -1;

    // 	}

    // }



    ans = func(arr , n , -1 , 0);



    cout<<ans<<endl;

}



int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL); cout.tie(NULL);

    

    

  //  int t; cin>>t; while(t--)

    {     

      solve();

    }



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.3727356438610268x):
// Created by Kshitij Anand NSIT

#include <bits/stdc++.h>





using namespace std;





#define int long long

#define pb push_back

#define P pair<int,int>

#define F first

#define S second

#define vi vector<int>

#define vc vector<char>

#define vb vector<bool>

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

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

#define mp(a, b) make_pair(a, b)

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

#define min4(a, b, c, d) min(min(a, b), min(c, d))

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

#define max4(a, b, c, d) max(max(a, b), max(c, d))

#define fill(arr,val) memset(arr,val,sizeof(arr))

#define db(x)  cout<<#x<<" : "<<x<<endl





const int N = 1000000007;



int func(int arr[][3] , int n){



	int dp[n][3] = {};



	dp[0][0] = arr[0][0];

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

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



	int prev = -1;





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



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

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

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

	}



	int ans = max3(dp[n-1][0] , dp[n-1][1] , dp[n-1][2]);

	return ans;

}



void solve(){



    int n,a,b,c, ans=0, count=0, sum=0;

    cin>>n;

    int arr[n][3];

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



    	for(int j=0; j<3; j++) {

	      cin>>arr[i][j];

    	}

    }



    ans = func(arr , n);

    cout<<ans<<endl;





}



int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(NULL); cout.tie(NULL);

    

    

  //  int t; cin>>t; while(t--)

    {     

      solve();

    }



  return 0;

}