import bisect

N = int(eval(input()))

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

ans = 1



def search(A,a,b):

    import bisect

    ans = bisect.bisect_right(A,b) - bisect.bisect_left(A,a)

    return ans



for i in range(A[-1]+1):

    ans = max(ans,search(A,i-1,i+1))

print(ans)
import bisect

N = int(eval(input()))

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

ans = 1



for i in range(A[-1]+1):

    ans = max(ans,bisect.bisect_right(A,i+1) - bisect.bisect_left(A,i-1))

print(ans)
import bisect

N = int(eval(input()))
A = sorted(list(map(int, input().split())))
ans = 1


def search(A, a, b):
    import bisect

    ans = bisect.bisect_right(A, b) - bisect.bisect_left(A, a)
    return ans


for i in range(A[-1] + 1):
    ans = max(ans, search(A, i - 1, i + 1))
print(ans)

import bisect

N = int(eval(input()))
A = sorted(list(map(int, input().split())))
ans = 1
for i in range(A[-1] + 1):
    ans = max(ans, bisect.bisect_right(A, i + 1) - bisect.bisect_left(A, i - 1))
print(ans)

- - -def search(A, a, b): -    import bisect - -    ans = bisect.bisect_right(A, b) - bisect.bisect_left(A, a) -    return ans - - -    ans = max(ans, search(A, i - 1, i + 1)) +    ans = max(ans, bisect.bisect_right(A, i + 1) - bisect.bisect_left(A, i - 1))