from collections import Counter



n=int(eval(input()))

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



min_v=min(a)

max_v=max(a)



c=Counter(a)



ans=0

for i in range(min_v,max_v+1):

  t_ans=c[i-1]+c[i]+c[i+1]

  ans=max(ans,t_ans)



print(ans)
from sys import stdin

nii=lambda:list(map(int,stdin.readline().split()))

lnii=lambda:list(map(int,stdin.readline().split()))

from collections import Counter



n=int(eval(input()))

a=lnii()



c=Counter(a)

a_max=max(a)



ans=0

for i in range(a_max+1):

  t_ans=c[i-1]+c[i]+c[i+1]

  ans=max(ans,t_ans)



print(ans)
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
min_v = min(a)
max_v = max(a)
c = Counter(a)
ans = 0
for i in range(min_v, max_v + 1):
    t_ans = c[i - 1] + c[i] + c[i + 1]
    ans = max(ans, t_ans)
print(ans)

from sys import stdin

nii = lambda: list(map(int, stdin.readline().split()))
lnii = lambda: list(map(int, stdin.readline().split()))
from collections import Counter

n = int(eval(input()))
a = lnii()
c = Counter(a)
a_max = max(a)
ans = 0
for i in range(a_max + 1):
    t_ans = c[i - 1] + c[i] + c[i + 1]
    ans = max(ans, t_ans)
print(ans)

+from sys import stdin + +nii = lambda: list(map(int, stdin.readline().split())) +lnii = lambda: list(map(int, stdin.readline().split())) -a = list(map(int, input().split())) -min_v = min(a) -max_v = max(a) +a = lnii() +a_max = max(a) -for i in range(min_v, max_v + 1): +for i in range(a_max + 1):