fun main(args: Array<String>) {
  var dpA = 0
  var dpB = 0
  var dpC = 0

  val n = readLine()!!.toInt()
  for (i in 0 until n) {
    val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }
    val prevA = dpA
    val prevB = dpB
    val prevC = dpC
    dpA = Math.max(prevB, prevC) + a
    dpB = Math.max(prevA, prevC) + b
    dpC = Math.max(prevB, prevA) + c
  }

  println(Math.max(dpA, Math.max(dpB, dpC)))
}

