import numpy as np

N = int(eval(input()))

A = np.array(input().split(), dtype = np.int32)

 

counter = np.bincount(A)

if len(counter) <= 2:

  answer = counter.sum()

else:

  answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()

print(answer)
from collections import Counter



n = int(eval(input()))

A = [int(i) for i in input().split()]

counts = Counter(A)



ans = 0

for k, v in list(counts.items()):

    tmp = v

    if k + 1 in list(counts.keys()):

        tmp += counts[k + 1]

    if k - 1 in list(counts.keys()):

        tmp += counts[k - 1]

    ans = max(tmp, ans)



print(ans)

import numpy as np

N = int(eval(input()))
A = np.array(input().split(), dtype=np.int32)
counter = np.bincount(A)
if len(counter) <= 2:
    answer = counter.sum()
else:
    answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer)

from collections import Counter

n = int(eval(input()))
A = [int(i) for i in input().split()]
counts = Counter(A)
ans = 0
for k, v in list(counts.items()):
    tmp = v
    if k + 1 in list(counts.keys()):
        tmp += counts[k + 1]
    if k - 1 in list(counts.keys()):
        tmp += counts[k - 1]
    ans = max(tmp, ans)
print(ans)

-import numpy as np +from collections import Counter -N = int(eval(input())) -A = np.array(input().split(), dtype=np.int32) -counter = np.bincount(A) -if len(counter) <= 2: -    answer = counter.sum() -else: -    answer = (counter[2:] + counter[1:-1] + counter[:-2]).max() -print(answer) +n = int(eval(input())) +A = [int(i) for i in input().split()] +counts = Counter(A) +ans = 0 +for k, v in list(counts.items()): +    tmp = v +    if k + 1 in list(counts.keys()): +        tmp += counts[k + 1] +    if k - 1 in list(counts.keys()): +        tmp += counts[k - 1] +    ans = max(tmp, ans) +print(ans)