#!/usr/bin/env ruby
# opt(i, c) = max{ h(ai) + opt(i+1, a), h(bi) + opt(i+1, b) }

n = STDIN.readline.strip.to_i
h = STDIN.read.split("\n").map{|l| l.split(' ').map(&:to_i)}

def opt(h)
  # puts "h:#{h}"
  m = []
  m[h.size-1] = h[-1]
  # puts "m:#{m}"
  (h.size-2).downto(0) do |i|
    m[i] = []
    [[1, 2], [0, 2], [0, 1]].each_with_index do |c, j|
      # puts "i:#{i}, c:#{c}, j:#{j}, m:#{m}"
      m[i][j] = c.map{|k| m[i+1][k] + h[i][j]}.max
    end
  end
  m[0].max
end

puts opt(h)
