N = gets.to_i
last = [0, 0, 0]
readlines.each do |s|
  a = s.split.map(&:to_i)
  [1,2,0,1].each_cons(2).with_index do |(j,k),i|
    x, y = a[i] + last[j], a[i] + last[k]
    last << (x < y ? y : x)
  end
  last.shift(3)
end
puts last.max
