n = gets.to_i
plan = n.times.map{ gets.split.map &:to_i }

dp = Array.new(n).map{Array.new(3).map{0}}
dp[0] = plan[0]

1.upto(n-1).each{|i|
    0.upto(2).each{|j|
        maxval = 0
        0.upto(2).each{|k|
            if j != k
                maxval = dp[i-1][k] if dp[i-1][k] > maxval
            end
        }
        dp[i][j] = maxval + plan[i][j]
    }
}

puts dp.last.max