fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = (0 until n).map {
        readLine()!!.split(' ').map { s -> s.toInt() }
    }

    val dp = Array(n + 1) { Array(3) { 0 } }

    (0 until n).forEach { i ->
        (0 until 3).forEach { j ->
            (0 until 3).forEach { k ->
                if (j != k) {
                    dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + a[i][k])
                }
            }
        }
    }

    println(dp.last().max())
}