import java.lang.Math.*

fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" ").map {it.toInt()}
    val a = Array(N){readLine()!!.split(" ").map{it.toInt()}}
    val dp = Array(N){Array(3){0} }
    for(i in 0 until 3) {
        dp[0][i] = a[0][i]
    }
        
    for(i in 1 until N) {
        for(k in 0 until 3)
        for(j in 0 until 3) {
            if(j==k)continue
            dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i][k])
        }
    }
    println(dp[N-1].max())
}

