P32 = 3.times.to_a.permutation(2) # no dup

def init
  [0] * 3
end

n = gets.to_i
# [a, b, c][]
ts = Array.new(n) { gets.split.map(&:to_i) }

dp = [init]
n.times do |i|
  # dp[i + 1] ||= init
  dp << init
  P32.each do |(j, k)|
    # change max
    cost = dp[i][j] + ts[i][k]
    dp[i + 1][k] = cost if dp[i + 1][k] < cost
  end
end

p dp.last.max
