CodeEff/ECCO huggingface dataset:
# Original solution
# encoding: "utf-8"

from collections import defaultdict
from functools import reduce
from itertools import groupby, chain

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]

def main():
    _ = eval(input())
    xs = Stdin.read_line(converter=int)
    ys = chain.from_iterable([[x-1, x, x+1] for x in xs])
    ys = sorted(list(ys))
    m = max([len([1 for _ in x]) for (i, x) in groupby(ys)])
    print(m)

if __name__ == "__main__":
    main()

# Optimized solution
# encoding: "utf-8"

from collections import defaultdict
from functools import reduce
from itertools import groupby, chain

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]

def main():
    _ = eval(input())
    xs = Stdin.read_line(converter=int)
    ys = chain.from_iterable([[x-1, x, x+1] for x in xs])
    ys = sorted(list(ys))
    cnt = 0
    m = 0
    prev = ys[0]
    for y in ys:
        if y == prev:
            cnt += 1
        else:
            if m < cnt:
                m = cnt
            prev = y
            cnt = 1
    print(m)

if __name__ == "__main__":
    main()
# Original solution
n=int(eval(input()))
al=list(map(int,input().split()))

dic={}
for v in al:
    if not v in list(dic.keys()):
        dic[v]=1
    else:
        dic[v]=dic[v]+1
count_l=[]
for v in range(min(al)-1,max(al)+2):
    count=0
    count=dic.get(v-1,0)+dic.get(v,0)+dic.get(v+1,0)
    count_l.append(count)
print((max(count_l)))

# Optimized solution
n = int(eval(input()))
#a, b = map(int,input().split())
al = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

dic = {}
for a in al:
    dic[a] = dic.get(a, 0)+1

mx = max(al)
mn = min(al)
ans = 0
for x in range(mn, mx+1):
    ans = max(ans, dic.get(x+1, 0)+dic.get(x, 0)+dic.get(x-1, 0))
print(ans)
# Original solution
n=int(eval(input()))
alis=list(map(int,input().split()))
xlis=set()
for i in alis:
    xlis.add(i-1)
    xlis.add(i+1)
    xlis.add(i)
#print(xlis)
counter=[0 for _ in range(len(xlis))]
t=-1
for x in xlis:
    t+=1
    for i in range(n):
        if x-1<=alis[i] and alis[i]<=x+1:
            counter[t]+=1
print((max(counter)))

# Optimized solution
n=int(eval(input()))
alis=list(map(int,input().split()))
xlis=dict()
for i in set(alis):
    xlis[i-1]=0
    xlis[i+1]=0
    xlis[i]=0
for i in alis:
    xlis[i-1]+=1
    xlis[i+1]+=1
    xlis[i]+=1
print((max(xlis.values())))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
p = [0] * 100005
for i in range(100005):
    p[i] += a.count(i - 1)
    p[i] += a.count(i)
    p[i] += a.count(i + 1)

print((max(p)))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted(a)
p = [0] * 100005
for i in a:
    p[i] += 1

num = 0
for i in range(1, 100000):
    num = max(num, sum(p[i - 1: i + 2]))

print(num)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
cntA = [0 for _ in range(10**5)]
for i in range(10**5):
    if i in A:
        cntA[i] = A.count(i)
sumA = [0 for _ in range(10**5)]
sumA[0] = cntA[0]
sumA[1] = cntA[0] + cntA[1]
for i in range(2,10**5):
    sumA[i] = cntA[i] + cntA[i-1] + cntA[i-2]
print((max(sumA)))

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort()
cntA = [0 for _ in range(10**5)]
for a in A:
        cntA[a] += 1
sumA = [0 for _ in range(10**5)]
sumA[0] = cntA[0]
sumA[1] = cntA[0] + cntA[1]
for i in range(2,10**5):
    sumA[i] = cntA[i] + cntA[i-1] + cntA[i-2]
print((max(sumA)))
# Original solution
from collections import Counter
n = int(eval(input()))
a = Counter(sorted(list(map(int, input().split()))))

ans = 0
p = 0
for x, y in list(a.items()):
    p = y
    if x-1 in a: p += a[x-1]
    if x+1 in a: p += a[x+1]
    if p > ans: ans = p
print(ans)

# Optimized solution
from collections import Counter
n = int(eval(input()))
a = Counter(list(map(int, input().split())))

ans = 0
for x,y in list(a.items()):
  cnt = y
  if x-1 in a: cnt += a[x-1]
  if x+1 in a: cnt += a[x+1]
  if cnt > ans: ans = cnt
print(ans)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))

if max(a)==min(a):
  print(n)
else:
  ans=1
  b=[0]*(10**6)
  for i in range(max(a)+1):
    b[i]=a.count(i)
  for i in range(10**5+3):
    ans=max(ans,b[i]+b[i+1]+b[i+2])
  print(ans)

# Optimized solution
import collections
n=int(eval(input()))
a=list(map(int,input().split()))
c=collections.Counter(a)
ans=1
for i in range(min(a),max(a)+1):
  goukei=c[i-1]+c[i]+c[i+1]
  ans=max(ans,goukei)
print(ans)
# Original solution
import sys
from collections import defaultdict

cnt = defaultdict(int)

def main():
    n, *a = list(map(int, sys.stdin.read().split()))
    a.sort()
    l = a[0]
    r = a[-1]

    for val in a:
        cnt[val] += 1
    
    ans = 0
    for i in range(l, r+1):
        ans = max(ans, cnt[i-1] + cnt[i] + cnt[i+1])

    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
import sys
from collections import defaultdict

n, *a = list(map(int, sys.stdin.read().split()))

def main():
    res = defaultdict(int)
    for i in a:
        res[i-1] += 1
        res[i] += 1
        res[i+1] += 1

    return max(res.values()) 
    
if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
import sys
from collections import defaultdict

n, *a = list(map(int, sys.stdin.read().split()))

def main():
    res = defaultdict(int)
    for i in a:
        res[i-1] += 1
        res[i] += 1
        res[i+1] += 1

    return max(res.values()) 
    
if __name__ == '__main__':
    ans = main()
    print(ans)

# Optimized solution
import sys

n, *a = list(map(int, sys.stdin.read().split()))

def main():
    m = 10 ** 5
    cnt = [0] * (m + 1)
    for x in a:
        cnt[x] += 1
        if x > 0: cnt[x-1] += 1
        if x < m: cnt[x+1] += 1
    print((max(cnt)))

if __name__ ==  '__main__':
    main()
# Original solution
n = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for num in range(min(A), max(A)+1):
    tmp = [1 if abs(a-num)<=1 else 0 for a in A]
    ans = max(ans, sum(tmp))
print(ans)

# Optimized solution
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
count = dict()
for a in A:
    for i in range(a-1, a+2):
        if i not in count:
            count[i] = 1
        else:
            count[i] += 1
print((max(count.values())))
# Original solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))

a_sorted = sorted(a)
a_v = list(Counter(a_sorted).values())
a_k = list(Counter(a_sorted).keys())
count_max = a_v[0]
for i in range(1, len(a_v)):
    count = 0
    if a_k[i] - a_k[i - 1] == 1: 
        count += a_v[i - 1]
    if i < (len(a_v) - 1) and a_k[i + 1] - a_k[i] == 1:
        count += a_v[i + 1]
    count += a_v[i]
    if count > count_max:
        count_max = count
print(count_max)

# Optimized solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))

a_c = Counter(sorted(a))
a_v = list(a_c.values())
a_k = list(a_c.keys())
count_max = a_v[0]
for i in range(1, len(a_v)):
    count = 0
    if a_k[i] - a_k[i - 1] == 1: 
        count += a_v[i - 1]
    if i < (len(a_v) - 1) and a_k[i + 1] - a_k[i] == 1:
        count += a_v[i + 1]
    count += a_v[i]
    if count > count_max:
        count_max = count
print(count_max)
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))

num = [0 for i in range(3)]
num[0] = a.count(0)
num[1] = a.count(1)

ans = 0
for X in range(1, 100000):
    num[(X % 3) - 2] = a.count(X + 1)
    ans = max(ans, sum(num))

print(ans)


# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))

num = [0 for i in range(100000)]
for aa in a:
    num[aa] += 1

ans = 0
for X in range(1, 99999):
    ans = max(ans, sum(num[X-1:X+2]))

print(ans)
# Original solution
from collections import defaultdict

N = eval(input())
counts = defaultdict(int)
values = set()
for a in map(int, input().split()):
    counts[a] += 1
    values.add(a)
ans = 0
for x in values:
    ans = max(ans, counts[x - 1] + counts[x] + counts[x + 1])
print(ans)


# Optimized solution
from collections import defaultdict

_ = eval(input())
counts = defaultdict(int)
for a in map(int, input().split()):
    counts[a] += 1
    counts[a - 1] += 1
    counts[a + 1] += 1
print((max(counts.values())))
# Original solution
from collections import defaultdict
N = eval(input())
a_raw = list(map(int, input().split()))
a_plus = [num + 1 for num in a_raw]
a_minus = [num - 1 for num in a_raw]
numbers = set(a_raw) | set(a_minus) | set(a_plus)
num_count = list()
for number in numbers:
    num_count.append(a_raw.count(number) + a_plus.count(number) + a_minus.count(number))

print((max(num_count)))

# Optimized solution
from collections import defaultdict as dd
N = eval(input())
a_raw = list(map(int, input().split()))
num_count = dd(int)
for item in a_raw:
    num_count[item] += 1
    num_count[item-1] += 1
    num_count[item+1] += 1
print((max(num_count.values())))
# Original solution
def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    A.sort()
    from collections import Counter, defaultdict
    c = defaultdict(int)
    for k, v in list(Counter(A).items()):
        c[k] = v
    ans = 0
    for i in range(10**5+1):
        if i != 0:
            cur = c[i] + c[i-1] + c[i+1]
        else:
            cur = c[i] + c[i+1]
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    from collections import Counter, defaultdict
    c = defaultdict(int)
    for k, v in list(Counter(A).items()):
        c[k] = v
    ans = 0
    for i in range(max(A) + 1):
        if i != 0:
            cur = c[i] + c[i-1] + c[i+1]
        else:
            cur = c[i] + c[i+1]
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    from collections import Counter, defaultdict
    c = defaultdict(int)
    for k, v in list(Counter(A).items()):
        c[k] = v
    ans = 0
    for i in range(max(A) + 1):
        if i != 0:
            cur = c[i] + c[i-1] + c[i+1]
        else:
            cur = c[i] + c[i+1]
        ans = max(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    max_A = max(A)
    counts = [0] * (max_A + 2)
    for a in A:
        if a > 0:
            counts[a-1] += 1
        counts[a] += 1
        counts[a+1] += 1
    print((max(counts)))


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
a = list(map(int,input().split()))

ans = 0
numcnt = {i:0 for i in range(100001)}

for i in a:
    numcnt[i]+=1
    
for x in range(1,100000):
    subans = numcnt[x-1]+numcnt[x]+numcnt[x+1]
        
    ans = max(ans,subans)
    
print(ans)

# Optimized solution
N = int(eval(input()))
a = list(map(int,input().split()))

ans = 0
numcnt = [0]*100001

for i in a:
    numcnt[i]+=1
    
for x in range(1,100000):
    subans = numcnt[x-1]+numcnt[x]+numcnt[x+1]
        
    ans = max(ans,subans)
    
print(ans)
# Original solution
N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(1,100000):
    cnt =0
    for x in a:
        if abs(i-x) <= 1:
            cnt += 1
    ans = max(ans,cnt)
print(ans)

# Optimized solution
import collections
N = int(eval(input()))
a = list(map(int,input().split()))
dic = collections.Counter(a)
ans = 0
for i in range(min(a),max(a)+1):
    cnt = dic[i-1]+dic[i]+dic[i+1]
    ans = max(ans,cnt)
print(ans)
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
cnt_a = [0] * (10**5 + 2)
for i in range(n):
    cnt_a[a[i]] += 1
max_cnt = 0
for i in range(1, 10**5 + 1):
    max_cnt = max(max_cnt, sum(cnt_a[i - 1:i + 2]))
print(max_cnt)

# Optimized solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
cnt_x = [0] * (10**5 + 2)
for i in range(n):
    cnt_x[a[i] - 1] += 1
    cnt_x[a[i]] += 1
    cnt_x[a[i] + 1] += 1
print((max(cnt_x)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split(" ")))

mmax = max(a)
mmin = min(a)
mcount = 0
for i in range(mmin, mmax + 1):
    count = 0
    count += a.count(i)
    count += a.count(i + 1)
    count += a.count(i - 1)
    if mcount < count:
        mcount = count

print(mcount)


# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split(" ")))

c_dic = {}
for i in a:
    if i not in c_dic:
        c_dic[i] = 1
    else:
        c_dic[i] += 1
    
    if i + 1 not in c_dic:
        c_dic[i + 1] = 1
    else:
        c_dic[i + 1] += 1

    if i - 1 not in c_dic:
        c_dic[i - 1] = 1
    else:
        c_dic[i - 1] += 1

print((max(c_dic.values())))
# Original solution
def main():
	N = int(eval(input()))
	a = list(map(int, input().split()))

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

	for X in range(10 ** 5 + 1):
		if X == 0:
			ans[0] += a.count(0)
			ans[0] += a.count(1)
		elif X == 10 ** 5:
			ans[10 ** 5] += a.count(10 ** 5 - 1)
			ans[10 ** 5] += a.count(10 ** 5 + 1)
		else:
			ans[X] += a.count(X - 1)
			ans[X] += a.count(X)
			ans[X] += a.count(X + 1)

	print((max(ans)))

 
if __name__ == "__main__":
  	main()

# Optimized solution
def main():
	N = int(eval(input()))
	a = list(map(int, input().split()))
	
	a_lst = [0] * (10 ** 5 + 1)
	for num in a:
		a_lst[num] += 1

	ans = 0
	for X in range(10 ** 5 + 1):
		cnt = 0

		if X == 0:
			cnt += a_lst[X]
			cnt += a_lst[X + 1]
		elif X == 10 ** 5:
			cnt += a_lst[X - 1]
			cnt += a_lst[X]
		else:
			cnt += a_lst[X - 1]
			cnt += a_lst[X]
			cnt += a_lst[X + 1]

		if cnt > ans:
			ans = cnt

	print(ans)



 
if __name__ == "__main__":
  	main()
# Original solution
from collections import defaultdict

n = int(eval(input()))

a_lis = list(map(int,input().split()))
A_dict = defaultdict(int)

for i in a_lis:
  A_dict[i] += 1
  
max_cnt = 0

for j in range(1, 10**5):
  tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
  max_cnt = max(max_cnt, tmp)
print(max_cnt)

# Optimized solution
from collections import defaultdict

n = int(eval(input()))
ans = 0

a_lis = list(map(int,input().split()))
A_dict = [0]*(10**5+1)

for i in a_lis:
  A_dict[i] += 1

for j in range(1,10**5):
  tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
  if tmp > ans:
    ans = tmp
print(ans)
# Original solution
from collections import defaultdict

n = int(eval(input()))
ans = 0

a_lis = list(map(int,input().split()))
A_dict = [0]*(10**5+1)

for i in a_lis:
  A_dict[i] += 1

for j in range(1,10**5):
  tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
  if tmp > ans:
    ans = tmp
print(ans)

# Optimized solution
def main():
  n = int(eval(input()))
  ans = 0
  a_lis = list(map(int,input().split()))
  A_dict = [0]*(10**5+1)
  for i in a_lis:
    A_dict[i] += 1
  for j in range(1,10**5):
    tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
    if tmp > ans:
      ans = tmp
  print(ans)

if __name__=='__main__':
  main()
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
w = max(a) - min(a) + 3
abucket = [0] * w
for i in range(n):
  abucket[a[i] - min(a)] += 1
  abucket[a[i] - 1 - min(a)] += 1
  abucket[a[i] + 1 - min(a)] += 1
print((max(abucket)))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
mina = min(a)
maxa = max(a)
w = maxa - mina + 3
abucket = [0] * w
for i in range(n):
  abucket[a[i] - mina] += 1
  abucket[a[i] - 1 - mina] += 1
  abucket[a[i] + 1 - mina] += 1
print((max(abucket)))
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 0
def count(i):
    res = 0
    for x in a[i:]:
        if x - a[i] <= 1:
            res += 1
    for y in a[:i]:
        if a[i] - y <= 1:
            res += 1
    return res

for i in range(n):
    ans = max(ans,count(i))
print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()

s = [0]*(a[-1]+1)
for i in range(n):
    s[a[i]] += 1
ans = 0
if a[-1] - 1 > 0:
    for i in range(1,a[-1]):
        ans = max(ans, s[i] + s[i-1] + s[i+1])
    print(ans)
else:
    print((max(s)))
# Original solution
from collections import Counter 
N = int(eval(input()))
A = Counter(list(map(int, input().split())))
cnt = 0
for i in A:
    sums = A[i] + A[i+1] + A[i+2]
    if sums > cnt:
        cnt = sums
print(cnt)

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
x = [0]*((10**5) + 2)
for i in a:
    x[i+1] += 1
    x[i] += 1
    x[i+2] += 1
print((max(x)))
# Original solution
import collections

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

a_processed = []

for i in a:
    a_processed[n:n] = [i-1, i, i+1]

print((a_processed.count(collections.Counter(a_processed).most_common()[0][0])))


# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

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

for i in a:
    ans_l[i-1] += 1
    ans_l[i] += 1
    ans_l[i+1] += 1

print((max(ans_l)))
# Original solution
N = int(eval(input()))
L = list(map(int, input().split())) 
res = 0
for i in range(10**5):
    count = L.count(i) + L.count(i+1) + L.count(i+2)
    if count > res:
        res = count
print(res)

# Optimized solution
N = int(eval(input()))
L = list(map(int, input().split()))
K = [ 0 for i in range(10**5)]
for i in range(N):
    K[L[i]] += 1
a = []   
res = 0
for i in range(len(K)):
    a.append(K[i])
    if len(a) > 3:
        a.pop(0)
    if sum(a) > res:
        res =sum(a)
print(res)
# Original solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
count_a = Counter(a)

result = []
for i in range(min(a),max(a)+1):
    result.append(count_a[i]+count_a[i-1]+count_a[i+1])
print((max(result)))

# Optimized solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
set_a = list(set(a))
#set_a = sorted(set_a)
count_a = Counter(a)

result = []
for i in set_a:
    result.append(count_a[i]+count_a[i-1]+count_a[i+1])
print((max(result)))
# Original solution
from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
c = []
for i in A:
    c.extend([i-1,i,i+1])
ans = Counter(c).most_common()
print((ans[0][1]))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a-1] = d.setdefault(a-1,0) + 1
    d[a] = d.setdefault(a,0) + 1
    d[a+1] = d.setdefault(a+1,0) + 1
print((max(d.values())))
# Original solution
N = int(eval(input()))
a = [int(i) for i in input().split()]
Min = min(a)-1
Max = max(a)+1
num = [[0 for i in range(N)] for j in range(Min, Max+1)]

idx = 0
for i in a:
    num[i-Min-1][idx] = 1
    num[i-Min][idx] = 1
    num[i-Min+1][idx] = 1
    idx += 1

ct = -1
for i in num:
    tmp = i.count(1)
    if tmp > ct:
        ct = tmp
        
print(ct)
        

# Optimized solution
N = int(eval(input()))
a = [int(i) for i in input().split()]
Min = min(a)-1
Max = max(a)+1
ans = [0 for i in range(Min, Max+1)]

for i in a:
    ans[i-Min-1] += 1
    ans[i-Min] += 1
    ans[i-Min+1] += 1
        
print((max(ans)))
# Original solution
N = int(eval(input()))
a = list(map(int,input().split()))
count = [0]*(10**5+1)
ans = 0
for X in range(10**5+2):
  for i in range(N):
    if X == a[i] or X == a[i]+1 or X == a[i]-1:
      count[X] += 1
ans = max(count)
print(ans)

# Optimized solution
import collections
N = int(eval(input()))
a = list(map(int,input().split()))
count = []
ans = 0
for i in range(N):
  count.append(a[i]-1)
  count.append(a[i])
  count.append(a[i]+1)
ans = max(collections.Counter(count).values())
print(ans)
# Original solution
n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
ans = 1
dic = {}
for i in range(10**5):
    dic[i] = 0
for i in a:
    dic[i] += 1
for i in range(1,10**5-1):
    ans = max(ans, dic[i-1] + dic[i] + dic[i+1])
print(ans)

# Optimized solution
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = [0] * 10**5
ans = 1
if n == 2:
    if abs(a[0] - a[1]) <= 2:
        ans = 2
for i in range(n):
    b[a[i]] += 1
for i in range(n-2):
    ans = max(ans, b[i]+b[i+1]+b[i+2])

print(ans)
# Original solution
N = int(eval(input()))
P = list(map(int,input().split()))

cnt = 0
tmp = []
for i in range(N):
    for j in range(N):
        if P[i] - 1 <= P[j] <= P[i] + 1:
            cnt += 1
    tmp.append(cnt)
    cnt = 0

print((max(tmp)))

# Optimized solution
N = int(eval(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)))
# Original solution
#
# abc072 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
3 1 4 1 5 9 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
0 1 2 3 4 5 6 7 8 9"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
99999"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(eval(input()))
    A = list(map(int, input().split()))

    an = {}
    for a in A:
        an.setdefault(a, 0)
        an[a] += 1

    ans = 1
    for x in range(min(A)-1, max(A)+1):
        t = 0
        for k, v in list(an.items()):
            if x == k-1 or x == k or x == k+1:
                t += v
        ans = max(ans, t)

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


# Optimized solution
#
# abc072 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """7
3 1 4 1 5 9 2"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
0 1 2 3 4 5 6 7 8 9"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1
99999"""
        output = """1"""
        self.assertIO(input, output)


def resolve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    AN = [0] * 100002  # -1 <= X <= 10^5+1

    for a in A:
        AN[a] += 1
        AN[a+1] += 1
        AN[a+2] += 1
    print((max(AN)))


if __name__ == "__main__":
    # unittest.main()
    resolve()