N = int(eval(input()))

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



def solve(cand):

	global a

	res = 0

	for ai in a:

		if ai - 1 == cand or ai == cand or ai + 1 == cand:

			res += 1

	return res



cnt = {}

for ai in a:

	for i in range(-1,2):

		b = ai + i

		if b >= 0:

			if b not in cnt:

				cnt[b] = 1

			else:

				cnt[b] += 1



candX = max(list(cnt.items()), key=lambda x:x[1])[0]

res = solve(candX);



print(res)
from collections import defaultdict



N = int(eval(input()))

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



cnt = defaultdict(int)

for ai in a:

	cnt[ai - 1] += 1

	cnt[ai] += 1

	cnt[ai + 1] += 1



res = max(cnt.values())



print(res)
N = int(eval(input()))
a = list(map(int, input().split()))


def solve(cand):
    global a
    res = 0
    for ai in a:
        if ai - 1 == cand or ai == cand or ai + 1 == cand:
            res += 1
    return res


cnt = {}
for ai in a:
    for i in range(-1, 2):
        b = ai + i
        if b >= 0:
            if b not in cnt:
                cnt[b] = 1
            else:
                cnt[b] += 1
candX = max(list(cnt.items()), key=lambda x: x[1])[0]
res = solve(candX)
print(res)

from collections import defaultdict

N = int(eval(input()))
a = list(map(int, input().split()))
cnt = defaultdict(int)
for ai in a:
    cnt[ai - 1] += 1
    cnt[ai] += 1
    cnt[ai + 1] += 1
res = max(cnt.values())
print(res)

+from collections import defaultdict + - - -def solve(cand): -    global a -    res = 0 -    for ai in a: -        if ai - 1 == cand or ai == cand or ai + 1 == cand: -            res += 1 -    return res - - -cnt = {} +cnt = defaultdict(int) -    for i in range(-1, 2): -        b = ai + i -        if b >= 0: -            if b not in cnt: -                cnt[b] = 1 -            else: -                cnt[b] += 1 -candX = max(list(cnt.items()), key=lambda x: x[1])[0] -res = solve(candX) +    cnt[ai - 1] += 1 +    cnt[ai] += 1 +    cnt[ai + 1] += 1 +res = max(cnt.values())