from sys import stdin

import bisect



n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))



li.sort()



ma = 0



if len(li) == 1:

    print((1))

elif len(li) == 2:

    if abs(li[0] - li[1]) <= 1:

        print((2))

    else:

        print((1))

else:

    for i in range(1,n-1):

        ma = max(ma,bisect.bisect(li,i+1)-bisect.bisect_left(li,i-1))



    print(ma)
n = int(eval(input()))

a = list(map(int,input().split()))



point = [0]*(10**5+2)



for i in a:

    if i == 1:

        point[1] += 1

        point[2] += 1

    else:

        point[i] += 1

        point[i-1] += 1

        point[i+1] += 1



print((max(point)))
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
li = list(map(int, stdin.readline().rstrip().split()))
li.sort()
ma = 0
if len(li) == 1:
    print((1))
elif len(li) == 2:
    if abs(li[0] - li[1]) <= 1:
        print((2))
    else:
        print((1))
else:
    for i in range(1, n - 1):
        ma = max(ma, bisect.bisect(li, i + 1) - bisect.bisect_left(li, i - 1))
    print(ma)

n = int(eval(input()))
a = list(map(int, input().split()))
point = [0] * (10**5 + 2)
for i in a:
    if i == 1:
        point[1] += 1
        point[2] += 1
    else:
        point[i] += 1
        point[i - 1] += 1
        point[i + 1] += 1
print((max(point)))

-from sys import stdin -import bisect - -n = int(stdin.readline().rstrip()) -li = list(map(int, stdin.readline().rstrip().split())) -li.sort() -ma = 0 -if len(li) == 1: -    print((1)) -elif len(li) == 2: -    if abs(li[0] - li[1]) <= 1: -        print((2)) +n = int(eval(input())) +a = list(map(int, input().split())) +point = [0] * (10**5 + 2) +for i in a: +    if i == 1: +        point[1] += 1 +        point[2] += 1 -        print((1)) -else: -    for i in range(1, n - 1): -        ma = max(ma, bisect.bisect(li, i + 1) - bisect.bisect_left(li, i - 1)) -    print(ma) +        point[i] += 1 +        point[i - 1] += 1 +        point[i + 1] += 1 +print((max(point)))