n = gets.to_i
h = Hash.new { |h,k| h[k] = {} }
n.times do |i|
  gets.chomp.split(' ').map(&:to_i).each.with_index do |j, idx|
    h[i][idx] = j
  end
end

def max(a, b)
  a > b ? a : b
end

dp = Hash.new { |h,k| h[k] = {} }
dp[0] = h[0]
(0...(n-1)).each do |i|
  3.times do |j|
    3.times do |k|
      next if j == k
      dp[i+1][k] = max(dp[i+1][k].to_i, dp[i][j] + h[i+1][k])
    end
  end
end

print(dp[n-1].values.max)
