fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var aSum = 0
    var bSum = 0
    var cSum = 0
    var aPrev = 0
    var bPrev = 0
    var cPrev = 0

    for ( i in 0 until n) {
        val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
        aSum = Math.max(bPrev, cPrev) + a
        bSum = Math.max(aPrev,cPrev) + b
        cSum = Math.max(aPrev,bPrev) + c

        aPrev = aSum
        bPrev = bSum
        cPrev = cSum
    }

    println(Math.max(Math.max(aSum, bSum), cSum))
}