program atcoder
    implicit none
    integer(8) :: i,n,a,b,c
    integer(8),allocatable,dimension(:,:) :: dp
    read*,n
    allocate(dp(0:n,0:2))
    dp = 0
    do i = 1,n
        read*,a,b,c
        dp(i,0) = max( dp(i-1,1) , dp(i-1,2) ) + a
        dp(i,1) = max( dp(i-1,0) , dp(i-1,2) ) + b
        dp(i,2) = max( dp(i-1,1) , dp(i-1,0) ) + c
    enddo
    write(*,'(I0)')max(dp(n,0),dp(n,1),dp(n,2))
    stop 
!---------------------------------------
contains

end program atcoder
