object Main extends App {
  val n = io.StdIn.readInt()
  val k = 3
  val actions = Array.fill(n)(io.StdIn.readLine().split(' ').map(_.toInt))
  val dp = Array.ofDim[Int](n,k)

  for (j <- 0 until k) dp(0)(j) = actions(0)(j)
  for (i <- 1 until n)
    for (j <- 0 until k) {
      dp(i)(j) = dp(i-1).zipWithIndex.filter(_._2 != j).maxBy(_._1)._1 + actions(i)(j)
    }

  println(dp(n-1).max)
}