N = gets.to_i
A = Array.new(N){gets.split.map &:to_i}
DP = [[0,0,0]]

N.times do |i|
    n = i + 1
    DP[n] = [0,0,0]
    3.times do |j|
        k = (j + 1) % 3
        l = (j + 2) % 3
        DP[n][j] = A[i][j] + [DP[i][k], DP[i][l]].max
    end
end

p DP[N].max