PROGRAM ATCODER

implicit none
integer :: n, k, i, j
integer, allocatable :: a(:,:), dp(:,:)

read(*,*) n
allocate(a(n,3), dp(n,3))
do i = 1, n
	read(*,*) (a(i,j), j=1,3)
end do

dp = 0
dp(1,1) = a(1,1)
dp(1,2) = a(1,2)
dp(1,3) = a(1,3)

do i = 2, n
	do j = 1, 3
    	do k = 1, 3
			if (j /= k)then
        		call chmax(dp(i,j), dp(i-1,k)+a(i,j))
        	end if
        end do
    end do
end do

write(*,'(i0)') maxval(dp)

END PROGRAM ATCODER

subroutine chmax(dp,x)
implicit none
integer :: dp, x

if (dp < x) then
	dp = x
	return
end if

end subroutine