n=gets.to_i
dp=Array.new(3,0)
pastdp=gets.split.map &:to_i
(n-1).times do
  dp=gets.split.map &:to_i
  0.upto(2) do |i|
    max=0
    0.upto(2) do |j|
      if i!=j && max < pastdp[j] 
        max=pastdp[j]
      end
    end
    dp[i] += max
  end
  pastdp=dp
end

print dp.max

