import sys

def I(): return int(sys.stdin.readline().rstrip())

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N = I()

a = LI()

ans = 0

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

for x in a:

    num_count[x] += 1

for i in range(10**5+1):

    if i+2<=10**5:

        ans = max(ans,sum(num_count[i:i+3]))

print(ans)

import sys

def I(): return int(sys.stdin.readline().rstrip())

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

N = I()

a = LI()

ans = 0

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

for x in a:

    num_count[x-1] += 1

    num_count[x] += 1

    num_count[x+1] += 1

print((max(num_count)))

import sys


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N = I()
a = LI()
ans = 0
num_count = [0] * (10**5 + 1)
for x in a:
    num_count[x] += 1
for i in range(10**5 + 1):
    if i + 2 <= 10**5:
        ans = max(ans, sum(num_count[i : i + 3]))
print(ans)

import sys


def I():
    return int(sys.stdin.readline().rstrip())


def LI():
    return list(map(int, sys.stdin.readline().rstrip().split()))


N = I()
a = LI()
ans = 0
num_count = [0] * (10**5 + 2)
for x in a:
    num_count[x - 1] += 1
    num_count[x] += 1
    num_count[x + 1] += 1
print((max(num_count)))

-num_count = [0] * (10**5 + 1) +num_count = [0] * (10**5 + 2) +    num_count[x - 1] += 1 -for i in range(10**5 + 1): -    if i + 2 <= 10**5: -        ans = max(ans, sum(num_count[i : i + 3])) -print(ans) +    num_count[x + 1] += 1 +print((max(num_count)))