n = gets.chomp.to_i
k = []
n.times do |i|
  k[i] = gets.chomp.split.map(&:to_i)
end

# dp[幸福のmax][前日に選んでたやつ]
dp = Array.new(10 ** 5 + 5) { Array.new(3, 0) }

1.upto(n) do |i|
  (0..2).each do |j| # 前日
    (0..2).each do |d| # 当日
      next if d == j
      dp[i][j] = [dp[i][j], dp[i-1][d] + k[i-1][d]].max
    end
  end
end
p dp[n].max
