program ABC072C
    implicit none
    integer(8)::N,count,result,i,j
    integer(8)::flg=0
    integer(8)::p1=0
    integer(8),allocatable,dimension(:)::A
    read(5,*)N
    allocate(A(N))
    read(5,*)(A(i),i=1,N)
    !A=iqsort(A)

    result=1
    count=0

    do i=minval(A),maxval(A)
        count=0
        do j=1,N
            if(A(j)==i.or.A(j)-1==i.or.A(j)+1==i)then
                count=count+1
            end if
        end do

        if(count>result)then
            result=count
        end if
    end do

    print'(i0)',result
end program ABC072C