You are given an integer sequence of length N, a_1,a_2,...,a_N.
For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.
After these operations, you select an integer X and count the number of i such that a_i=X.
Maximize this count by making optimal choices.

-----Constraints-----
 - 1≤N≤10^5
 - 0≤a_i<10^5 (1≤i≤N)
 - a_i is an integer.

-----Input-----
The input is given from Standard Input in the following format:
N
a_1 a_2 .. a_N

-----Output-----
Print the maximum possible number of i such that a_i=X.

-----Sample Input-----
7
3 1 4 1 5 9 2

-----Sample Output-----
4

For example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.

Source: atcoder | Difficulty: EASY


Solutions:
n = int(input())
a = list(map(int, input().split()))
d = [0] * (10 ** 5 + 10)
for av in a:
	for x in [-1, 0, 1]:
		d[av + x + 1] += 1
print(max(d))


n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = [0] * 100001
for i in a:
	cnt[i] += 1
for i in range(len(cnt) - 2):
	ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2])
print(ans)


from collections import defaultdict
d = defaultdict(int)
N = int(input())
N_List = list(map(int, input().split()))
for i in range(N):
	CN = N_List[i]
	for k in range(-1, 2, 1):
		d[CN + k] += 1
print(max(d.values()))


import sys, math
from functools import lru_cache
from itertools import accumulate
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

def input():
	return sys.stdin.readline()[:-1]

def mi():
	return list(map(int, input().split()))

def ii():
	return int(input())

def i2(n):
	tmp = [list(mi()) for i in range(n)]
	return [list(i) for i in zip(*tmp)]
N = ii()
a = list(mi())
l = [0] * (max(a) + 5)
for i in range(N):
	l[a[i]] += 1
	l[a[i] + 3] -= 1
acc = list(accumulate(l))
print(max(acc))


import sys
import collections
(N, *A) = map(int, open(0).read().split())
B = collections.Counter(A).most_common()
B.sort(key=lambda x: x[0])
ans = 0
for i in range(len(B)):
	count = B[i][1]
	if i + 1 < len(B) and B[i + 1][0] == B[i][0] + 1:
		count += B[i + 1][1]
		if i + 2 < len(B) and B[i + 2][0] == B[i][0] + 2:
			count += B[i + 2][1]
	ans = max(ans, count)
print(ans)


import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(lambda x: x - 1, a))
c = list(map(lambda y: y + 1, a))
d = a + b + c
e = collections.Counter(d)
print(max(e.values()))


n = int(input())
al = list(map(int, input().split()))
ans = [0] * (10 ** 5 + 2)
for a in al:
	ans[a] += 1
	ans[a - 1] += 1
	ans[a + 1] += 1
print(max(ans))


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
p = [0] * (max(a) + 5)
for i in range(n):
	p[a[i] + 1] += 1
res = 0
for i in range(min(a), max(a) + 1):
	res = max(res, p[i] + p[i + 1] + p[i + 2])
print(res)


(N, *A) = map(int, open(0).read().split())
L = [0 for i in range(int(100000.0) + 1)]
for a in A:
	L[a] += 1
ans = 0
for i in range(int(100000.0) + 1):
	S = sum(L[i:i + 3])
	if ans < S:
		ans = S
print(ans)


n = int(input())
a = list(map(int, input().split()))
num_list = [0] * 10 ** 5
for i in range(n):
	num_list[a[i]] += 1
res = 0
for i in range(1, 10 ** 5 - 1):
	res = max(res, num_list[i - 1] + num_list[i] + num_list[i + 1])
print(res)


n = int(input())
a = list(map(int, input().split()))
c = [0] * (10 ** 5 + 3)
for i in range(n):
	c[a[i]] += 1
	c[a[i] - 1] += 1
	c[a[i] + 1] += 1
print(max(c))


n = int(input())
al = list(map(int, input().split()))
al.sort()
al.append(-1)
cnt = 1
bl = []
for i in range(n):
	if al[i] == al[i + 1]:
		cnt += 1
	else:
		bl.append([al[i], cnt])
		cnt = 1
tmp = 0
ans = 0
for j in range(len(bl)):
	tmp = bl[j][1]
	if bl[j - 1][0] + 1 == bl[j][0]:
		tmp += bl[j - 1][1]
	if j != len(bl) - 1 and bl[j][0] == bl[j + 1][0] - 1:
		tmp += bl[j + 1][1]
	if tmp > ans:
		ans = tmp
print(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (10 ** 5 + 1)
for i in a:
	cnt[i] += 1
x_cnt = [0] * (10 ** 5 + 1)
for x in range(1, 10 ** 5):
	tmp = cnt[x - 1] + cnt[x] + cnt[x + 1]
	x_cnt[x] = tmp
print(max(x_cnt))


(N, *A) = map(int, open(0).read().split())
C = {}
for a in A:
	if a in C.keys():
		C[a] += 1
	else:
		C[a] = 1
B = list(C.items())
B.sort(key=lambda x: x[0])
ans = 0
for i in range(len(B)):
	count = B[i][1]
	try:
		for j in [-1, 1]:
			if B[i + j][0] == B[i][0] + j:
				count += B[i + j][1]
	except IndexError:
		pass
	ans = max(ans, count)
print(ans)


from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = []
for a in A:
	B.append(a - 1)
	B.append(a)
	B.append(a + 1)
C = Counter(B)
print(C.most_common()[0][1])


import collections
n = int(input())
a = list(map(int, input().split()))
lower_a = list(map(lambda x: x - 1, a))
upper_a = list(map(lambda x: x + 1, a))
extended_a = collections.Counter(a + lower_a + upper_a)
print(extended_a.most_common()[0][1])


input()
B = [0] * 10 ** 5
for a in input().split():
	B[int(a)] += 1
print(max((sum(B[i:i + 3]) for i in range(10 ** 5))))


from collections import defaultdict

def main():
	_ = input()
	a = [int(an) for an in input().split()]
	cnt = defaultdict(int)
	for an in a:
		cnt[an - 1] += 1
		cnt[an] += 1
		cnt[an + 1] += 1
	print(max(cnt.values()))

def __starting_point():
	main()
__starting_point()


import numpy as np
n = int(input())
a = np.array(sorted(map(int, input().split())))
d = np.array([0] * (10 ** 5 + 3))
e = np.array([0] * (10 ** 5 + 3))
f = np.array([0] * (10 ** 5 + 3))
for i in a:
	d[i + 1] += 1
b = a - 1
for i in b:
	e[i + 1] += 1
c = a + 1
for i in c:
	f[i + 1] += 1
g = d + e + f
print(max(g))


import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
counter = np.bincount(A)
if len(counter) <= 2:
	answer = counter.sum()
else:
	answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer)


N = int(input())
a = list(map(int, input().split()))
res = 0
count = [0] * (10 ** 5 + 2)
for i in range(N):
	count[a[i]] += 1
for i in range(10 ** 5):
	x = count[i] + count[i + 1] + count[i - 1]
	res = max(res, x)
print(res)


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
a = [i - 1 for i in l]
b = [i + 1 for i in l]
l = Counter(l + a + b)
print(l.most_common()[0][1])


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(int)
for x in arr:
	d[x] += 1
a = d[0] + d[1] + d[2]
ans = [a]
for i in range(max(arr) - 2):
	a -= d[i]
	a += d[i + 3]
	ans.append(a)
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
data = [0] * (10 ** 5 + 2)
for i in a:
	data[i] += 1
	data[i + 1] += 1
	data[i + 2] += 1
print(max(data))


n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
	cnt[v] += 1
	cnt[v + 1] += 1
	cnt[v + 2] += 1
print(max(cnt))


from collections import defaultdict
d = defaultdict(int)
N = int(input())
a = list(map(int, input().split()))
for x in a:
	d[x] += 1
	d[x - 1] += 1
	d[x + 1] += 1
print(max(d.values()))


N = int(input())
l = list(map(int, input().split()))
flag = [0] * (max(l) + 2)
minone = 0
for i in l:
	if i == 0:
		minone += 1
	else:
		flag[i - 1] += 1
	flag[i] += 1
	flag[i + 1] += 1
print(max(max(flag), minone))


N = int(input())
a = list(map(int, input().split()))
count = [0] * (10 ** 5 + 1)
for i in range(N):
	count[a[i]] += 1
	if a[i] - 1 >= 0:
		count[a[i] - 1] += 1
	if a[i] + 1 <= 10 ** 5:
		count[a[i] + 1] += 1
max_value = max(count)
print(max_value)


N = int(input())
A = [int(x) for x in input().split()]
data = {}
for a in A:
	for i in range(3):
		if a - 1 + i in data:
			data[a - 1 + i] += 1
		else:
			data[a - 1 + i] = 1
ans = 0
for d in data.values():
	ans = max(ans, d)
print(ans)


import collections
n = int(input())
a = list(map(int, input().split()))
a1 = [x - 1 for x in a]
a2 = [x + 1 for x in a]
b = a + a1 + a2
c = collections.Counter(b)
print(max(c.values()))


n = int(input())
a = list(map(int, input().split()))
dp = [0 for i in range(max(a) + 1)]
for i in range(n):
	dp[a[i]] += 1
ans = 0
if len(dp) == 1:
	ans = dp[0]
else:
	for i in range(1, len(dp) - 1):
		ans = max(ans, dp[i - 1] + dp[i] + dp[i + 1])
print(ans)


N = int(input())
a = list(map(int, input().split()))
Q = [0] * (max(a) + 3)
for i in a:
	Q[i] += 1
	Q[i + 1] += 1
	Q[i + 2] += 1
print(max(Q))


import collections
N = int(input())
As = sorted(list(map(int, input().split())))
c = collections.Counter(As)
L = [0] * (10 ** 5 + 1)
M = [0] * (10 ** 5 + 1)
for (x, y) in list(c.items()):
	L[x] = y
for i in range(0, 10 ** 5):
	M[i] = L[i - 1] + L[i] + L[i + 1]
print(max(M))


N = int(input())
A = list(map(int, input().split()))
A = [i + 1 for i in A]
bucket = [0] * (10 ** 5 + 10)
for a in A:
	bucket[a - 1] += 1
	bucket[a] += 1
	bucket[a + 1] += 1
print(max(bucket))


from collections import Counter
import copy

def LI():
	return list(map(int, input().split()))
N = int(input())
A = LI()
B = Counter(A)
A = copy.copy(B)
for (k, v) in B.items():
	if k - 1 in A:
		A[k - 1] += v
	else:
		A[k - 1] = v
	if k + 1 in A:
		A[k + 1] += v
	else:
		A[k + 1] += v
print(max(A.values()))


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
d = defaultdict(int)
for x in arr:
	d[x] += 1
	d[x - 1] += 1
	d[x + 1] += 1
result = [y for (x, y) in d.items()]
print(max(result))


import collections
n = int(input())
a_list = list(map(int, input().split()))
max_cnt = 0
c = collections.Counter(a_list)
for i in range(max(c.keys()) + 1):
	cnt = c[i] + c[i + 1] + c[i + 2]
	if max_cnt < cnt:
		max_cnt = cnt
print(max_cnt)


n = int(input())
a = list(map(int, input().split()))
p = []
for i in range(n):
	p.append(a[i] - 1)
	p.append(a[i])
	p.append(a[i] + 1)
from collections import Counter
c = Counter(p).most_common()
m = list(c)[0][0]
ans = 0
for i in range(n):
	if abs(a[i] - m) <= 1:
		ans += 1
print(ans)


n = int(input())
A = list(map(int, input().split()))
X = [0] * (10 ** 5 + 5)
for a in A:
	X[a] += 1
	X[a + 1] += 1
	X[a - 1] += 1
print(max(X))


import statistics
N = int(input())
A = list(map(int, input().split()))
ans = []
for a in A:
	ans.append(a)
	ans.append(a - 1)
	ans.append(a + 1)
mode = statistics.mode(ans)
print(ans.count(mode))


import sys
input = lambda : sys.stdin.readline().rstrip()

def main():
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * (max(a) + 3)
	for i in a:
		cnt[i - 1] += 1
		cnt[i] += 1
		cnt[i + 1] += 1
	print(max(cnt))

def __starting_point():
	main()
__starting_point()


N = int(input())
a = list(map(int, input().split()))
mode = [0] * (10 ** 5 + 2)
for i in range(len(a)):
	k = a[i]
	if a == 0:
		mode[k] += 1
		mode[k + 1] += 1
	else:
		mode[k - 1] += 1
		mode[k] += 1
		mode[k + 1] += 1
print(max(mode))


N = int(input())
A = list(map(int, input().split()))
ans = 0
A.sort()
a = 0
b = 0
c = 1
for i in range(N - 1):
	if A[i] == A[i + 1]:
		a += 1
		b += 1
		c += 1
	elif A[i] + 1 == A[i + 1]:
		if ans < a:
			ans = a
		a = b
		a += 1
		b = c
		b += 1
		c = 1
	elif A[i] + 2 == A[i + 1]:
		if ans < a:
			ans = a
		if ans < b:
			ans = b
		a = c
		a += 1
		b = 1
		c = 1
	else:
		if ans < a:
			ans = a
		if ans < b:
			ans = b
		if ans < c:
			ans = c
		a = 1
		b = 1
		c = 1
if ans < a:
	ans = a
if ans < b:
	ans = b
if ans < c:
	ans = c
print(ans)


N = int(input())
A = [int(x) for x in input().split()]
d = [0] * (10 ** 5 + 1)
for a in A:
	if a - 1 >= 0:
		d[a - 1] += 1
	d[a] += 1
	d[a + 1] += 1
ans = max(d)
print(ans)


import collections
N = int(input())
List = list(map(int, input().split()))
sumList = []
for i in range(N):
	sumList.append(List[i])
	sumList.append(List[i] + 1)
	sumList.append(List[i] - 1)
c = collections.Counter(sumList)
print(c.most_common()[0][1])


N = int(input())
a = list(map(lambda x: int(x), input().split(' ')))
sums = [0] * (10 ** 5 + 1)
for val in a:
	if val - 1 >= 0:
		sums[val - 1] = sums[val - 1] + 1
	sums[val] = sums[val] + 1
	if val + 1 <= 10 ** 5:
		sums[val + 1] = sums[val + 1] + 1
print(max(sums))


import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10 ** 6)

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

def z():
	return int(sys.stdin.readline())

def S():
	return sys.stdin.readline()[:-1]

def C(line):
	return [sys.stdin.readline() for _ in range(line)]
N = z()
A = zz()
c = collections.Counter(A)
ans = 0
for x in range(max(A) + 1):
	tmp = c[x]
	try:
		tmp += c[x - 1]
	except:
		pass
	try:
		tmp += c[x + 1]
	except:
		pass
	ans = max(tmp, ans)
print(ans)


N = int(input())
A = list(map(int, input().split()))
count = [0] * (10 ** 5 + 1)
for a in A:
	count[a] += 1
ans = 0
for i in range(1, 10 ** 5):
	X = count[i - 1] + count[i] + count[i + 1]
	ans = max(ans, X)
print(ans)


n = int(input())
lis = list(map(int, input().split()))
con = [0] * (10 ** 5 + 2)
for v in lis:
	con[v] += 1
	con[v + 1] += 1
	con[v + 2] += 1
print(max(con))


N = int(input())
A = list(map(int, input().split()))
co = [0 for i in range(100002)]
for i in A:
	co[i] += 1
ans = 0
for i in range(100001):
	if i == 0:
		x = co[0] + co[1]
	else:
		x = co[i - 1] + co[i] + co[i + 1]
	ans = max(ans, x)
print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = 0
l = [0] * (10 ** 5 + 2)
for i in range(n):
	l[a[i]] += 1
for i in range(10 ** 5):
	x = l[i] + l[i + 1] + l[i - 1]
	ans = max(ans, x)
print(ans)


N = int(input())
A = list(map(int, input().split()))
K = max(A)
ls = [0 for i in range(K + 2)]
for i in range(N):
	if A[i] == 0:
		ls[A[i]] += 1
		ls[A[i] + 1] += 1
	else:
		ls[A[i] - 1] += 1
		ls[A[i]] += 1
		ls[A[i] + 1] += 1
print(max(ls))


import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
ans = 0
for (value, count) in counter.items():
	if value - 1 in counter:
		count += counter[value - 1]
	if value + 1 in counter:
		count += counter[value + 1]
	ans = max(ans, count)
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
a_list = list(map(int, input().split()))
sort_a_list = sorted(a_list)
l = 0
r = 0
ans = 0
max_ans = 0
sabun = 0
while r < n:
	if sabun <= 2:
		if sort_a_list[r] - sort_a_list[l] > 2:
			l += 1
			sabun = sort_a_list[r] - sort_a_list[l]
			ans -= 1
			continue
		ans += 1
		max_ans = max(max_ans, ans)
		r += 1
		if r >= n:
			break
		sabun = sort_a_list[r] - sort_a_list[l]
	else:
		l += 1
		sabun = sort_a_list[r] - sort_a_list[l]
		ans -= 1
print(max_ans)


import numpy as np
n = int(input())
alist = map(int, input().split())
sort = np.zeros(10 ** 5 + 1)
for a in alist:
	sort[a] += 1
max = 0
for i in range(10 ** 5 - 2):
	tmp = sort[i:i + 3].sum()
	if max < tmp:
		max = tmp
print(int(max))


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= 1
c = [0 for _ in range(100005)]
for i in range(n):
	val = a[i]
	c[val - 1] += 1
	c[val] += 1
	c[val + 1] += 1
ans = 0
for i in range(100005):
	ans = max(ans, c[i])
print(ans)


def main():
	_ = int(input())
	A = list(map(int, input().split()))
	B = [0] * 100002
	ans = 0
	for a in A:
		if a != 0:
			B[a - 1] += 1
		B[a] += 1
		B[a + 1] += 1
	ans = max(B)
	print(ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = sorted(list(map(int, input().split(' '))))
counter = [0 for i in range(10 ** 5 + 2)]
ans = 0
for i in range(n):
	counter[a[i]] += 1
for i in range(1, 10 ** 5 + 1):
	temp = sum(counter[i - 1:i + 2])
	ans = max(ans, temp)
print(ans)


import collections
N = int(input())
a = list(map(int, input().split()))
for i in range(len(a)):
	if a[i] > 0:
		a.append(a[i] - 1)
	a.append(a[i] + 1)
res = collections.Counter(a)
print(max(res.values()))


N = int(input())
a = map(int, input().split())
result_num_list = [0] * (10 ** 5 + 5)
for i in a:
	result_num_list[i - 1] += 1
	result_num_list[i] += 1
	result_num_list[i + 1] += 1
print(max(result_num_list))


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	m = 10 ** 5
	l = [0] * m
	for i in range(n):
		if a[i] >= 1:
			l[a[i] - 1] += 1
		l[a[i]] += 1
		if a[i] < m - 1:
			l[a[i] + 1] += 1
	print(max(l))

def __starting_point():
	main()
__starting_point()


n = int(input())
arr = [int(x) for x in input().split()]
cnt = [0] * (10 ** 5 + 1)
for a in arr:
	cnt[a] += 1
	cnt[a + 1] += 1
	if a > 0:
		cnt[a - 1] += 1
print(max(cnt))


from sys import stdin, stdout

def increment_dict(a_dict, element):
	if element in a_dict:
		a_dict[element] = a_dict[element] + 1
	else:
		a_dict[element] = 1

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	mp = dict()
	best_count = 0
	for num in a:
		increment_dict(mp, num)
		increment_dict(mp, num - 1)
		increment_dict(mp, num + 1)
		best_count = max(best_count, mp[num], mp[num - 1], mp[num + 1])
	print(best_count)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


N = int(input())
A = list(map(int, input().split()))
ans = [0] * (max(A) + 2)
for a in A:
	if a == 0:
		ans[a] += 1
		ans[a + 1] += 1
	if a != 0:
		ans[a - 1] += 1
		ans[a] += 1
		ans[a + 1] += 1
print(max(ans))


N = int(input())
a = sorted([int(c) for c in input().split()])
(c1, c2, c3) = [0, 0, 0]
ma = 1
for i in range(N):
	if i > 0:
		if a[i] == a[i - 1] + 1:
			c1 = c2
			c2 = c3
			c3 = i
		elif a[i] != a[i - 1]:
			(c1, c2, c3) = [i, i, i]
	if ma < i - c1 + 1:
		ma = i - c1 + 1
print(ma)


N = int(input())
A_list = list(map(int, input().split()))
A_dict = dict()
for a in A_list:
	if A_dict.get(a) is None:
		A_dict[a] = 1
	else:
		A_dict[a] += 1
ans = 0
for (key, val) in list(A_dict.items()):
	temp = 0
	if A_dict.get(key - 1) is not None:
		temp += A_dict.get(key - 1)
	if A_dict.get(key) is not None:
		temp += A_dict.get(key)
	if A_dict.get(key + 1) is not None:
		temp += A_dict.get(key + 1)
	ans = max(temp, ans)
print(ans)


import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
rr = lambda : sys.stdin.readline().rstrip()
rs = lambda : sys.stdin.readline().split()
ri = lambda : int(sys.stdin.readline())
rm = lambda : list(map(int, sys.stdin.readline().split()))
rl = lambda : list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10 ** 9 + 7
n = ri()
a = rl()
c = collections.Counter(a)
ans = 0
if n == 1:
	print(1)
	return
if n == 2:
	if abs(a[0] - a[1]) == 1:
		print(2)
		return
	else:
		print(1)
		return
for i in range(10 ** 5 + 2):
	ans = max(ans, c[i] + c[i + 1] + c[i + 2])
print(ans)


import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.bincount(np.array(A, dtype='int64'))
Ans = A.copy()
Ans[1:] += A[:-1]
Ans[:-1] += A[1:]
print(max(Ans))


(N, *A) = map(int, open(0).read().split())
C = {}
for a in A:
	if a in C.keys():
		C[a] += 1
	else:
		C[a] = 1
B = list(C.items())
B.sort(key=lambda x: x[0])
ans = 0
for i in range(len(B)):
	count = B[i][1]
	if i + 1 < len(B) and B[i + 1][0] == B[i][0] + 1:
		count += B[i + 1][1]
		if i + 2 < len(B) and B[i + 2][0] == B[i][0] + 2:
			count += B[i + 2][1]
	ans = max(ans, count)
print(ans)


from collections import Counter
with open(0) as f:
	(N, *a) = map(int, f.read().split())
data = [x - 1 for x in a] + [x for x in a] + [x + 1 for x in a]
ans = Counter(data).most_common(1)[0][1]
print(ans)


N = input()
ls = [int(s) for s in input().split()]
num = [0 for s in range(1000001)]
for i in ls:
	num[i] += 1
ans = [num[i - 1] + num[i] + num[i + 1] for i in range(100000)]
print(max(ans))


input()
c = [0] * 10 ** 6
for i in input().split():
	for j in (0, 1, 2):
		c[int(i) + j] += 1
print(max(c))


N = int(input())
a = list(map(int, input().split()))
count = [0 for _ in range(100001)]
for x in a:
	count[x] += 1
	count[x + 1] += 1
	if x > 0:
		count[x - 1] += 1
print(max(count))


N = int(input())
A = list(map(int, input().split()))
ans = 0
cnt = [0] * (10 ** 5 + 10)
for i in range(N):
	cnt[A[i]] += 1
for i in range(0, 100000):
	sum = cnt[i] + cnt[i + 1] + cnt[i + 2]
	ans = max(ans, sum)
print(ans)


from collections import defaultdict
N = int(input())
a = tuple(map(int, input().split()))
cnt = defaultdict(int)
for i in range(N):
	cnt[a[i] - 1] += 1
	cnt[a[i]] += 1
	cnt[a[i] + 1] += 1
print(max(cnt.values()))


n = int(input())
a = list(map(int, input().split()))
import collections
lis = collections.Counter(a)
ans = 0
memo = 0
for i in range(10 ** 5):
	memo = lis[i - 1] + lis[i] + lis[i + 1]
	if memo > ans:
		ans = memo
print(ans)


N = int(input())
a = [int(x) for x in input().split()]
M = max(a)
C = [0] * (M + 1)
for i in range(N):
	C[a[i]] += 1
ans = 0
for i in range(1, M):
	wa = C[i - 1] + C[i] + C[i + 1]
	ans = max(ans, wa)
if M <= 1:
	ans = N
print(ans)


from collections import Counter
ans = []
N = int(input())
a = list(map(int, input().split()))
num = Counter(a)
for i in set(a):
	ans.append(num[i] + num[i + 1] + num[i - 1])
print(max(ans))


cnt = [0] * 100002
input()
for x in map(int, input().split()):
	cnt[x] += 1
	cnt[x + 1] += 1
	cnt[x + 2] += 1
print(max(cnt))


import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
d = np.array([0] * (10 ** 5 + 2))
for i in a:
	for j in (-1, 0, 1):
		d[i + 1 + j] += 1
print(max(d))


N = int(input())
A = list(map(int, input().split()))
nums = [0] * 100000
ans_list = []
for i in range(N):
	nums[A[i]] += 1
for j in range(1, 99999):
	ans_list.append(nums[j - 1] + nums[j] + nums[j + 1])
print(max(ans_list))


import sys
N = int(input())
A = list(map(int, input().split()))
if N == 1:
	print(1)
	return
cnt = [0 for _ in range(10 ** 5 + 1)]
for a in A:
	if a == 0:
		cnt[a] += 1
		cnt[a + 1] += 1
	else:
		cnt[a - 1] += 1
		cnt[a] += 1
		cnt[a + 1] += 1
print(max(cnt))


N = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
a_set = set(a)
a_cnt = [0] * (max(a) + 2)
for i in a:
	a_cnt[i] += 1
mcnt = 0
for j in a:
	cnt = a_cnt[j]
	if j - 1 in a_set:
		cnt += a_cnt[j - 1]
	if j + 1 in a_set:
		cnt += a_cnt[j + 1]
	mcnt = max(mcnt, cnt)
print(mcnt)


import collections
N = int(input())
lsA = list(map(int, input().split()))
counterA = collections.Counter(lsA)
ans = 0
for X in range(1, 10 ** 5 + 1):
	b1 = counterA[X - 1]
	b2 = counterA[X]
	b3 = counterA[X + 1]
	ans = max(ans, sum([b1, b2, b3]))
print(ans)


n = int(input())
a_lst = list(map(int, input().split()))
for i in range(n):
	a_lst[i] += 1
max_a = max(a_lst)
count_lst = [0] * (max_a + 2)
for i in range(n):
	a = a_lst[i]
	index1 = a - 1
	index2 = a
	index3 = a + 1
	count_lst[index1] += 1
	count_lst[index2] += 1
	count_lst[index3] += 1
maximum = max(count_lst)
print(maximum)


n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b += [a[i], a[i] + 1, a[i] - 1]
import collections
c = collections.Counter(b)
print(c.most_common()[0][1])


import sys
pin = sys.stdin.readline

def main():
	N = int(pin())
	a = list(map(int, pin().split()))
	d = [0] * 10 ** 5
	for i in a:
		d[i] += 1
	ans = 0
	for i in range(10 ** 5 - 2):
		ans = max(ans, d[i] + d[i + 1] + d[i + 2])
	print(ans)
	return
main()


n = int(input())
numbers = list(map(int, input().split()))
number_colle = [0] * (10 ** 5 + 2)
for i in range(n):
	choise = numbers[i] + 1
	for j in [-1, 0, 1]:
		number_colle[choise + j] += 1
print(max(number_colle))