import sys

import itertools

import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, *a = list(map(int, read().split()))

a.sort()



A = [0] * (10**5 + 1)

for i in a:

    A[i] += 1

cnt = 0

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

    cnt = max(cnt, A[i - 1] + A[i] + A[i + 1])

print(cnt)

import sys

import itertools

import numpy as np



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N, *a = list(map(int, read().split()))

A = np.array(a)



counter = np.bincount(A)

B = counter.copy()

B[1:] += counter[:-1]

B[:-1] += counter[1:]



print((B.max()))

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *a = list(map(int, read().split()))
a.sort()
A = [0] * (10**5 + 1)
for i in a:
    A[i] += 1
cnt = 0
for i in range(1, 10**5 - 1):
    cnt = max(cnt, A[i - 1] + A[i] + A[i + 1])
print(cnt)

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, *a = list(map(int, read().split()))
A = np.array(a)
counter = np.bincount(A)
B = counter.copy()
B[1:] += counter[:-1]
B[:-1] += counter[1:]
print((B.max()))

-a.sort() -A = [0] * (10**5 + 1) -for i in a: -    A[i] += 1 -cnt = 0 -for i in range(1, 10**5 - 1): -    cnt = max(cnt, A[i - 1] + A[i] + A[i + 1]) -print(cnt) +A = np.array(a) +counter = np.bincount(A) +B = counter.copy() +B[1:] += counter[:-1] +B[:-1] += counter[1:] +print((B.max()))