from collections import Counter

n = int(eval(input()))

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



ans = 0

p = 0

for x, y in list(a.items()):

    p = y

    if x-1 in a: p += a[x-1]

    if x+1 in a: p += a[x+1]

    if p > ans: ans = p

print(ans)
from collections import Counter

n = int(eval(input()))

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



ans = 0

for x,y in list(a.items()):

  cnt = y

  if x-1 in a: cnt += a[x-1]

  if x+1 in a: cnt += a[x+1]

  if cnt > ans: ans = cnt

print(ans)
from collections import Counter

n = int(eval(input()))
a = Counter(sorted(list(map(int, input().split()))))
ans = 0
p = 0
for x, y in list(a.items()):
    p = y
    if x - 1 in a:
        p += a[x - 1]
    if x + 1 in a:
        p += a[x + 1]
    if p > ans:
        ans = p
print(ans)

from collections import Counter

n = int(eval(input()))
a = Counter(list(map(int, input().split())))
ans = 0
for x, y in list(a.items()):
    cnt = y
    if x - 1 in a:
        cnt += a[x - 1]
    if x + 1 in a:
        cnt += a[x + 1]
    if cnt > ans:
        ans = cnt
print(ans)

-a = Counter(sorted(list(map(int, input().split())))) +a = Counter(list(map(int, input().split()))) -p = 0 -    p = y +    cnt = y -        p += a[x - 1] +        cnt += a[x - 1] -        p += a[x + 1] -    if p > ans: -        ans = p +        cnt += a[x + 1] +    if cnt > ans: +        ans = cnt