from collections import Counter

N = int(eval(input()))



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



d = Counter(A)



ans = 0

for i in range(1, 10**5+1):

    tmp = d[i-1] + d[i] + d[i+1]

    ans = max(tmp, ans)

print(ans)

from collections import Counter

N = int(eval(input()))



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



d = Counter(A)



ans = 0

for k in list(d.keys()):

    tmp = d[k-1] + d[k] + d[k+1]

    ans = max(ans, tmp)

print(ans)

from collections import Counter

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

from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
d = Counter(A)
ans = 0
for k in list(d.keys()):
    tmp = d[k - 1] + d[k] + d[k + 1]
    ans = max(ans, tmp)
print(ans)

-for i in range(1, 10**5 + 1): -    tmp = d[i - 1] + d[i] + d[i + 1] -    ans = max(tmp, ans) +for k in list(d.keys()): +    tmp = d[k - 1] + d[k] + d[k + 1] +    ans = max(ans, tmp)