program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i, ans,numc(0:100000)
    integer(int32), allocatable:: a(:)

    read*, n
    allocate(a(n))
    read*, a(:)
    numc(:) = 0
    do i=1,n
        numc(a(i)) = numc(a(i)) + 1
    end do
    ans=0

    do i=1,99999
        ans=max(ans,sum(numc(i-1:i+1)))
    end do

    print*, ans
end program name