program EDPCC
    implicit none
    integer(8)::N,i,j,k
    integer(8),dimension(3,100001)::H,dp
    read(5,*)N

    do i=1,N
        read(5,*)(H(j,i),j=1,3)
    end do

    dp=0

    do i=1,N+1
        do j=1,3
            do k=1,3
                if(j/=k)then
                    if(dp(j,i)+H(k,i)>dp(k,i+1))then
                        dp(k,i+1)=dp(j,i)+H(k,i)
                    end if
                end if
            end do
        end do
    end do

    print'(i0)',max(dp(1,N+1),max(dp(2,N+1),dp(3,N+1)))
end program EDPCC