n = gets.to_i
dp = Array.new(n+10){Array.new(3, 0)}
happy = []
n.times do |i|
  happy << gets.split.map(&:to_i) 
end

n.times do |i|
  3.times do |k|
    3.times do |l|
      dp[i+1][l] = [dp[i+1][l], dp[i][k]+happy[i][l]].max if k != l # k -> lへの遷移
    end
  end
end

#p happy
#p dp
p dp[n].max