      PROGRAM Vacation
      IMPLICIT NONE
      integer :: n
      integer,allocatable :: abcTable(:,:)
      integer :: day,Yday,Today
      integer,allocatable :: dp(:,:)
      
      read*,n
      allocate(abcTable(n,3),dp(0:n,3) )
      do day = 1,n
        read*,abcTable(day,:)
      end do
      
      dp = 0
      !dp(day,abc)当日に行動abcをとった場合のday(終了時)での最大値
      
      !abcHielaux,abcHodiaux
      do day = 1,n
        do Today = 1,3
          do Yday = 1,3
            if( Today==Yday )cycle
            dp(day,Today) = max( dp(day,Today), &
              &dp(day-1,Yday)+abcTable(day,Today) )
          end do
        end do
      end do
      
      print*,maxval(dp(n,:))
      
      
      END PROGRAM