def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def ang(n) Array.new(n){gsmi} end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

$stdin = File.open('input.txt') if File.exist?('input.txt')
n = gi
abcs = ang n

dp = Array.new(n){Array.new(3)}
dp[0] = abcs[0]
(1...n).each do |i|
  3.times do |j|
    dp[i][j] = abcs[i][j] + dp[i-1].map.with_index { |m,i| i==j ? 0 : m }.max
  end
end

puts dp[-1].max
