fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val dp = Array(3) { LongArray(n + 1) }

    for (i in 0 until n) {
        val xs = readLine()!!.split(' ').map { it.toLong() }
        for (j in 0 until 3) {
            dp[j][i + 1] = Math.max(dp[(j + 1) % 3][i] + xs[j], dp[(j + 2) % 3][i] + xs[j])
        }
    }

    println((0 until 3).map { dp[it][n] }.max())
}
