program name
    implicit none
    integer(4):: n,cnt(0:100000)
    integer(4),allocatable:: a(:)
    integer(4):: i, mcnt

    read*, n
    allocate(a(n))
    read*, a(:)

    cnt(:) = 0

    do i=1,n
        cnt(a(i)) = cnt(a(i)) + 1
    end do
    mcnt=0
    do i=1,99999
        mcnt=max(mcnt,sum(cnt(i-1:i+1)))
    end do

    print*, mcnt
end program name