import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

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



    if n == 1:

        print((1))

    else:

        L = []

        for i in range(n):

            L.append(list(range(A[i] - 1, A[i] + 2)))



        ma = L[-1][-1]

        mi = L[0][0]

        res = [0] * (ma - mi + 1)

        for l in L:

            for i in l:

                res[i - mi] += 1



        print((max(res)))





if __name__ == '__main__':

    resolve()

import sys

from collections import Counter

sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

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



    for i in range(n):

        A.append(A[i] - 1)

        A.append(A[i] + 1)



    D = Counter(A)

    res = 0

    for v in list(D.values()):

        res = max(res, v)



    print(res)



if __name__ == '__main__':

    resolve()

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    A = sorted(list(map(int, input().split())))
    if n == 1:
        print((1))
    else:
        L = []
        for i in range(n):
            L.append(list(range(A[i] - 1, A[i] + 2)))
        ma = L[-1][-1]
        mi = L[0][0]
        res = [0] * (ma - mi + 1)
        for l in L:
            for i in l:
                res[i - mi] += 1
        print((max(res)))


if __name__ == "__main__":
    resolve()

import sys
from collections import Counter

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    for i in range(n):
        A.append(A[i] - 1)
        A.append(A[i] + 1)
    D = Counter(A)
    res = 0
    for v in list(D.values()):
        res = max(res, v)
    print(res)


if __name__ == "__main__":
    resolve()

+from collections import Counter -    A = sorted(list(map(int, input().split()))) -    if n == 1: -        print((1)) -    else: -        L = [] -        for i in range(n): -            L.append(list(range(A[i] - 1, A[i] + 2))) -        ma = L[-1][-1] -        mi = L[0][0] -        res = [0] * (ma - mi + 1) -        for l in L: -            for i in l: -                res[i - mi] += 1 -        print((max(res))) +    A = list(map(int, input().split())) +    for i in range(n): +        A.append(A[i] - 1) +        A.append(A[i] + 1) +    D = Counter(A) +    res = 0 +    for v in list(D.values()): +        res = max(res, v) +    print(res)