fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    var a = Array<Int>(n,{0})
    var b = Array<Int>(n,{0})
    var c = Array<Int>(n,{0})
    var dp = Array(3){IntArray(n){0}}


    for(i in 0 until n){
        val (ai,bi,ci) = readLine()!!.split(" ").map{it.toInt()}
        a[i] = ai
        b[i] = bi
        c[i] = ci

    }
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];

    for(i in 1 until n){

        dp[0][i] = Math.max(dp[1][i-1],dp[2][i-1])+a[i]
        dp[1][i] = Math.max(dp[0][i-1],dp[2][i-1])+b[i]
        dp[2][i] = Math.max(dp[0][i-1],dp[1][i-1])+c[i]
    }



    println(Math.max(dp[0][n-1],Math.max(dp[1][n-1],dp[2][n-1])))

}
