from collections import Counter

n = int(eval(input()))

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

b = [i+1 for i in a]

c = [i-1 for i in a]



d = dict(Counter(a) + Counter(b) + Counter(c))

print((max(d.values())))
from collections import Counter

n = int(eval(input()))

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

c = Counter(a)

d = list(c.keys())

q = 1

for i in range(1,len(d)-1):

	if d[i+1] - d[i] == 1 and d[i] - d[i-1] == 1:

		s = c[d[i-1]] + c[d[i]] + c[d[i+1]]

		q = max(q,s)

	if i == 1:

		if d[i] - d[i-1] == 1:

			s = c[d[i-1]] + c[d[i]]

			q = max(q, s)

	if d[i+1] - d[i] == 1:

		s = c[d[i+1]] - c[d[i]]

		q = max(q, s)

if len(d) == 1:

	q = c[d[0]]

if len(d) == 2:

	if d[1] - d[0] == 1:

		q = c[d[1]] + c[d[0]]

	else:

		q = max(1, c[d[1]], c[d[0]])

print (q)
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
b = [i + 1 for i in a]
c = [i - 1 for i in a]
d = dict(Counter(a) + Counter(b) + Counter(c))
print((max(d.values())))

from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
d = list(c.keys())
q = 1
for i in range(1, len(d) - 1):
    if d[i + 1] - d[i] == 1 and d[i] - d[i - 1] == 1:
        s = c[d[i - 1]] + c[d[i]] + c[d[i + 1]]
        q = max(q, s)
    if i == 1:
        if d[i] - d[i - 1] == 1:
            s = c[d[i - 1]] + c[d[i]]
            q = max(q, s)
    if d[i + 1] - d[i] == 1:
        s = c[d[i + 1]] - c[d[i]]
        q = max(q, s)
if len(d) == 1:
    q = c[d[0]]
if len(d) == 2:
    if d[1] - d[0] == 1:
        q = c[d[1]] + c[d[0]]
    else:
        q = max(1, c[d[1]], c[d[0]])
print(q)

-b = [i + 1 for i in a] -c = [i - 1 for i in a] -d = dict(Counter(a) + Counter(b) + Counter(c)) -print((max(d.values()))) +c = Counter(a) +d = list(c.keys()) +q = 1 +for i in range(1, len(d) - 1): +    if d[i + 1] - d[i] == 1 and d[i] - d[i - 1] == 1: +        s = c[d[i - 1]] + c[d[i]] + c[d[i + 1]] +        q = max(q, s) +    if i == 1: +        if d[i] - d[i - 1] == 1: +            s = c[d[i - 1]] + c[d[i]] +            q = max(q, s) +    if d[i + 1] - d[i] == 1: +        s = c[d[i + 1]] - c[d[i]] +        q = max(q, s) +if len(d) == 1: +    q = c[d[0]] +if len(d) == 2: +    if d[1] - d[0] == 1: +        q = c[d[1]] + c[d[0]] +    else: +        q = max(1, c[d[1]], c[d[0]]) +print(q)