import java.lang.Integer.max

fun main() {
    val n = readLine()!!.toInt()
    val act = List(n) { readLine()!!.split(" ").map { it.toInt() } }

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

    for (i in 1..n) {
        dp[i][0] = max(dp[i - 1][1] + act[i - 1][0], dp[i - 1][2] + act[i - 1][0])
        dp[i][1] = max(dp[i - 1][0] + act[i - 1][1], dp[i - 1][2] + act[i - 1][1])
        dp[i][2] = max(dp[i - 1][0] + act[i - 1][2], dp[i - 1][1] + act[i - 1][2])
    }
    println(dp[n].max())
}