object Main extends App {

  import scala.io.StdIn._

  val n = readLine.trim.toInt
  val happiness = Array.tabulate(n){_ ⇒
    val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)
    Happiness(a, b, c)
  }
  println(solve(happiness))
  def solve(happiness: Array[Happiness]): Long = {
    val memo = Array.tabulate(happiness.length){_ ⇒ Array.tabulate(3){_ ⇒ None: Option[Long]}}
    def calMax(happiness: Array[Happiness], current: Int, prev: Int, memo: Array[Array[Option[Long]]]): Long = {
      if (current == happiness.length) 0L
      else {
        memo(current)(prev) match {
          case Some(r) ⇒ r
          case None ⇒ (1 to 2).map(i ⇒ (i + prev) % 3).map { next ⇒ calMax(happiness, current + 1, next, memo) + happiness(current)(next) }.max.also { max ⇒ memo(current)(prev) = Some(max) }
        }
      }
    }
    for (i ← (happiness.indices by 1000).reverse) calMax(happiness, i, 0, memo)
    (0 until 3).map(i ⇒ calMax(happiness, 0, i, memo)).max
  }
  case class Happiness(a: Int, b: Int, c: Int) {
    def apply(nTh:Int): Int = nTh match {
      case 0 ⇒ a
      case 1 ⇒ b
      case 2 ⇒ c
      case _ ⇒ ???
    }
  }
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}