import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	var last = IntArray(3){scn.nextInt()}
	repeat(n-1){
		val hps = IntArray(3){scn.nextInt()}
		last = IntArray(3){l ->
			val i = mutableListOf(0,1,2)
			i.removeAt(l)
			return@IntArray i.map{ last[it] }.max()!!+hps[l]
		}
	}
	print(last.max())
}