
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val ABCN = Array(N) { readLine()!!.split(" ").map(String::toInt) }

    val dp = Array(N) { IntArray(3) }

    dp[0][0] = ABCN[0][0]
    dp[0][1] = ABCN[0][1]
    dp[0][2] = ABCN[0][2]

    for (i in 1 until dp.size) {
        val a = dp[i - 1][0]
        val b = dp[i - 1][1]
        val c = dp[i - 1][2]

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

    println(dp[N - 1].max())
}
