from collections import Counter

def solve():

    ans = 0

    N = int(eval(input()))

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

    c = Counter(A)

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

        cnt = 0

        if i-1 in c:

            cnt += c[i-1]

        if i in c:

            cnt += c[i]

        if i+1 in c:

            cnt += c[i+1]

        ans = max(ans,cnt)   

    return ans

print((solve()))
def solve():

  ans = 0

  N = int(eval(input()))

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

  lis = [0]*(10**5+2)

  for i in range(N):

    lis[A[i]-1] += 1

    lis[A[i]] += 1

    lis[A[i]+1] += 1

  ans = max(lis)

  return ans

print((solve()))
from collections import Counter


def solve():
    ans = 0
    N = int(eval(input()))
    A = list(map(int, input().split()))
    c = Counter(A)
    for i in range(1, 10**5 - 1):
        cnt = 0
        if i - 1 in c:
            cnt += c[i - 1]
        if i in c:
            cnt += c[i]
        if i + 1 in c:
            cnt += c[i + 1]
        ans = max(ans, cnt)
    return ans


print((solve()))

def solve():
    ans = 0
    N = int(eval(input()))
    A = list(map(int, input().split()))
    lis = [0] * (10**5 + 2)
    for i in range(N):
        lis[A[i] - 1] += 1
        lis[A[i]] += 1
        lis[A[i] + 1] += 1
    ans = max(lis)
    return ans


print((solve()))

-from collections import Counter - - -    c = Counter(A) -    for i in range(1, 10**5 - 1): -        cnt = 0 -        if i - 1 in c: -            cnt += c[i - 1] -        if i in c: -            cnt += c[i] -        if i + 1 in c: -            cnt += c[i + 1] -        ans = max(ans, cnt) +    lis = [0] * (10**5 + 2) +    for i in range(N): +        lis[A[i] - 1] += 1 +        lis[A[i]] += 1 +        lis[A[i] + 1] += 1 +    ans = max(lis)