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

dp = Array.new(10001).map{Array.new(4, 0)}
n.times do |i|
  3.times do |j|
    3.times do |k|
      next if j == k
      dp[i + 1][k] = [dp[i + 1][k], dp[i][j] + a[i][k]].max
    end
  end
end

puts dp[n].max