from collections import Counter

N = int(eval(input()))

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

 

C = Counter(A)

ans = 0

for i in range(10**5):

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

  ans = max(c,ans)

  

print(ans)
import collections

n = int(eval(input()))

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

lst = collections.defaultdict(int)

for i in a:

  lst[i] += 1

  lst[i-1] += 1

  lst[i+1] += 1

  

lst = sorted(list(lst.items()),reverse=True,key=lambda x:x[1])

print((lst[0][1]))
from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for i in range(10**5):
    c = C[i - 1] + C[i] + C[i + 1]
    ans = max(c, ans)
print(ans)

import collections

n = int(eval(input()))
a = list(map(int, input().split()))
lst = collections.defaultdict(int)
for i in a:
    lst[i] += 1
    lst[i - 1] += 1
    lst[i + 1] += 1
lst = sorted(list(lst.items()), reverse=True, key=lambda x: x[1])
print((lst[0][1]))

-from collections import Counter +import collections -N = int(eval(input())) -A = list(map(int, input().split())) -C = Counter(A) -ans = 0 -for i in range(10**5): -    c = C[i - 1] + C[i] + C[i + 1] -    ans = max(c, ans) -print(ans) +n = int(eval(input())) +a = list(map(int, input().split())) +lst = collections.defaultdict(int) +for i in a: +    lst[i] += 1 +    lst[i - 1] += 1 +    lst[i + 1] += 1 +lst = sorted(list(lst.items()), reverse=True, key=lambda x: x[1]) +print((lst[0][1]))