fun main(args: Array<String>) {
    val (N) = readLine()!!.split(" "). map { it.toInt() }
    var dp1 = IntArray(3)
    for (i in 0 until N) {
        val dp2 = IntArray(3)
        val h = readLine()!!.split(" "). map { it.toInt() }
        for (j in 0 until 3) {
            for (k in 0 until 3) {
                if (i != 0 && j == k) continue
                dp2[j] = Math.max(dp2[j], dp1[k] + h[j])
            }
        }
        dp1 = dp2
    }
    println(dp1.max())
}