//                                                                                                         
//                    |    |                    |         ,---.     o               |    
//,---.,---.,---.,---.|---.|__/ ,---.,---.,---.' ,---.    `---.,---..,---.,---.,---.|--- 
//|---'|   ||    |   ||   ||  \ ,---||   |,---|  `---.        ||   |||   ||   ||---'|     
//`---'|---'`---'`   '`   '`   ``---^|---'`---^  `---'    `---'`   '`|---'|---'`---'`---'
//     |                             |                               |    |   
//								.    , '|      /|
//								|    |  |     / |
//								 \  /   |    /__|_ 
//								  `'    | o     |
//      Version 1.4 patchnotes{
//			New Feature: Dying for the river flowing
//			New defines: finding the max and min of three integers
//			New Poetry: Rose,violet
//			New quotes: Russian proverb
//			Bug fixes
//		}        
//
//In the name of Allah the beneficent, the merciful
//Here the Special Forces come
//I know a thing and it is that I dont know nothing
//One day all turks will be gone crazy, then god bless you
//There's no ugly women, there's less vodka
//Sub to Mcan
//
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
//
//_______________%%%%%%%%%%%%%%__________________________________
//_____________%%%%%%%%%%%%%%%%%_________________________________
//____________%%%%%%%%%%%%%%%%%%%________________________________
//__________%%%%%%%%%%%%%%%%%%%%%%%______________________________
//__________%%%%%%%%%%%%%%%%%%%%%%%%_____________________________
//________%%%%%%%%%%%%%%%_____%%%%%%%____________________________
//________%%%%%%%%%%%%___________%%%%____________________________
//_______%%%%%%%%%%%%_____________%%%%___________________________
//_______%%%%%%%%%%%_______________%%%___________________________
//______%%%%%%%%%%%_________________%%%_____%%___________________
//______%%%%%%%%%%__________________________%%%__________________
//______%%%%%%%%%___________________________%%%__________________
//_____%%%%%%%%%%___________________________%%%%_________________
//_____%%%%%%%%%____________________________%%%%%%%%%%%%_________
//_____%%%%%%%%%___________________________%%%%%%%%%%%___________
//_____%%%%%%%%%_________________________%%%%%%%%%%%%____________
//_____%%%%%%%%%_______________________%%%%%%%%%%%%%_____________
//_____%%%%%%%%%_____________________%%%%%%%%%%%%%%%_____________
//_____%%%%%%%%%_________________________%%%%%%%%%%%_____________
//_____%%%%%%%%%___________________________%%%%%%%%%%____________
//_____%%%%%%%%%%___________________________%%%%%%%%%%___________
//______%%%%%%%%%___________________________%%%%%%%%%%___________
//______%%%%%%%%%___________________________%%%%____%%%__________
//_______%%%%%%%%%__________________________%%%_______%%_________
//_______%%%%%%%%%%_________________%_______%%__________%________
//________%%%%%%%%%%_______________%%_______%____________________
//________%%%%%%%%%%%_____________%%%____________________________
//_________%%%%%%%%%%%%%________%%%%_____________________________
//__________%%%%%%%%%%%%%%%%%%%%%%%______________________________
//___________%%%%%%%%%%%%%%%%%%%%%_______________________________
//____________%%%%%%%%%%%%%%%%%%%________________________________
//_____________%%%%%%%%%%%%%%%%%_________________________________
//______________%%%%%%%%%%%%%%%__________________________________
//_______________%%%%%%%%%%%%%___________________________________
//__________________%%%%%%%%_____________________________________
// _   __, _ __,   __,  _, __,   , _  _, _,_ __,   __, _ _,_ __, __,   __, _,   _, _  _ _ _, _  _,
// |   | \ | |_    |_  / \ |_)   \ | / \ | | |_)   |_) | | / |_  |_)   |_  |   / \ |  | | |\ | / _
// |   |_/ | |_    |   \ / | \    \| \ / |_| | \   | \ | |/  |   | \   |   | , \ / |/\| | | \| \ /
// ~   ~   ~ ~~~   ~    ~  ~ ~     )  ~  `~' ~ ~   ~ ~ ~ ~   ~~~ ~ ~   ~   ~~~  ~  ~  ~ ~ ~  ~  ~ 
//                                ~'                                                              
//
//        ⣠⣶⣾⣿⣿⢶⣶⡶⠦
//⠀⠀⠀⠀⠀⢀⣾⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⢢
//⠀⠀⠀⠀⠀⢸⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡄

//⠀⠀⠀⠀⠀⢸⣿⠃⠀⢀⣠⣶⡆⢠⣶⣖⣻⣎⡇

//⠀⠀⠀⠀⠀⠁⡜⡄⠀⠉⠝⠋⠁⠘⣿⢿⡿⣳⠁

//⠀⠀⠀⠀⠀⠀⠀⣆⠀⠀⡠⠫⢤⣠⣿⡆⢘⡏

//⠀⠀⠀⠀⠀⠀⠀⣿⣦⡀⢧⣷⣬⢿⣽⣿⣾⠃

//⠀⠀⠀⢀⣴⣇⠙⣿⣿⣏⠚⠻⢿⣻⡿⠁

//⣤⣴⣶⣿⣿⣿⣿⣆⠈⠙⢿⣷⣾⣾⡿⣤⣤⣀

//⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠙⢿⠟⠁⣿⣿⣿⣿⣶⣄⡀

//⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⣠⣾⣦⡀⠸⣿⣿⣿⣿⣿⣿⣧

//⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠈⣿⣿⠃⠀⢿⣷⣿⣿⣿⣿⣿
//
//  __                                                             
// /  |                                                           |
//(___| ___  ___  ___  ___       ___  ___  ___       ___  ___  ___|
//|\   |   )|___ |___)|___      |   )|   )|___)     |   )|___)|   )
//| \  |__/  __/ |__   __/      |__/||    |__       |    |__  |__/ 
//                                                                 
//                                                                       
//|    |      /      /                                  /    /          
//(    )   ___ (  ___ (___  ___       ___  ___  ___      (___ (       ___ 
// \  /| |   )| |___)|    |___      |   )|   )|___)     |   )| |   )|___)
//  \/ | |__/ | |__  |__   __/      |__/||    |__       |__/ | |__/ |__  
//                                                                       
//
//  __                                                                                  __                  
// /|  /                   /                 /                                         /  |      /          
//( | (___  ___  ___  ___     ___       ___ (       ___       ___       ___  ___      (___| ___    ___  ___ 
//  | |   )|___)|   )|___)   |___      |   )| |   )|   )\   )|___      |   )|   )     |   )|___ | |   )|   )
//  | |  / |__  |    |__      __/      |__/|| |/\/ |__/| \_/  __/      |__/||  /      |  /  __/ | |__/||  / 
//                                                       /                                                 
//
//  __                                                                       
//|/  |      /    /                   /    /                                 
//|___| ___ (___ (___  ___  ___      (___ (___  ___  ___            ___      
//|   )|___)|    |    |___)|   )     |    |   )|   )|   )     \   )|   )|   )
//|__/ |__  |__  |__  |__  |         |__  |  / |__/||  /       \_/ |__/ |__/ 
//                                                             /            

//"Insert Problem name and code here"
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define nl '\n'
#define max3(a, b, c) max(max(a, b),c)
#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define fillar(x) for(int i=0;i<x;i++)cin>>ar[i]
#define qquery int query;cin>>query;while(query--)
#define benfero freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
int main(){
ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//benfero
	int n;
	cin>>n;
	int ar[n][3];
	for(int i=0;i<n;i++){
		cin >>ar[i][0]>>ar[i][1]>>ar[i][2];
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			if(j==0){
				ar[i][j]+=max(ar[i-1][j+1],ar[i-1][j+2]);
			}
			if(j==1){
				ar[i][j]+=max(ar[i-1][j-1],ar[i-1][j+1]);
			}
			if(j==2){
				ar[i][j]+=max(ar[i-1][j-1],ar[i-1][j-2]);
			}
		}
	}
	cout<<max3(ar[n-1][0],ar[n-1][1],ar[n-1][2]);
}

Measured memory_bytes: 1408