private var N = 0
private var list: Array<List<Int>> = emptyArray()
private var memo: MutableMap<Pair<Int, Int>, Long> = mutableMapOf()
/**
 * 再帰メモ化
 * @param args Array<String>
 */
fun main(args: Array<String>) {

    N = readLine()!!.toInt()
    list = Array(N) {
        readLine()!!.split(" ").map(String::toInt)
    }

    val result = mutableListOf<Long>()
    for (i in 0 until 3) {
        result.add(calc(N - 1, i))
    }
    println(result.max())
}

private fun calc(i: Int, current: Int): Long {

    if (memo.containsKey(i to current)) {
        return memo[i to current]!!
    }

    val currentScore = list[i][current].toLong()

    if (i == 0) {
        return currentScore
    }

    val (one, two) = (0..2).filterNot { it == current }


    return memo.getOrPut(
        i to current, {
            currentScore + Math.max(
                calc(i - 1, one),
                calc(i - 1, two)
            )
        }
    )
}