# frozen_string_literal: true

n = gets.to_i
happies = Array.new(n) { gets.split.map(&:to_i) }

sum = Array.new(n + 1) { Array.new(3, 0) }

(0..n - 1).each do |i|
  sum[i + 1][0] = [sum[i][1] + happies[i][0], sum[i][2] + happies[i][0]].max
  sum[i + 1][1] = [sum[i][0] + happies[i][1], sum[i][2] + happies[i][1]].max
  sum[i + 1][2] = [sum[i][0] + happies[i][2], sum[i][1] + happies[i][2]].max
end

puts sum.last.max
