fun main() {
    val n = readLine()!!.toInt()

    val aList = IntArray(n)
    val bList = IntArray(n)
    val cList = IntArray(n)
    for (i in 0 until n) {
        val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
        aList[i] = a
        bList[i] = b
        cList[i] = c
    }

    val dp = Array(n) { IntArray(3) }
    dp[0][0] = aList[0]
    dp[0][1] = bList[0]
    dp[0][2] = cList[0]

    for (i in 1 until n) {
        dp[i][0] = dp[i - 1][1].coerceAtLeast(dp[i - 1][2]) + aList[i]
        dp[i][1] = dp[i - 1][0].coerceAtLeast(dp[i - 1][2]) + bList[i]
        dp[i][2] = dp[i - 1][0].coerceAtLeast(dp[i - 1][1]) + cList[i]
    }

    var answer = dp[n - 1][0].coerceAtLeast(dp[n - 1][1]).coerceAtLeast(dp[n - 1][2])

    print(answer)
}

