CodeEff/ECCO huggingface dataset:
# Original solution
#ABC 072 C
N=int(eval(input()))
A=[int(j) for j in input().split()]
cnt=[0]*(10**6)
for a in A:
    cnt[a]+=1
    cnt[a+1]+=1
    cnt[a+2]+=1
print((max(cnt)))

# Optimized solution
#ABC 072 C
N=int(eval(input()))
A=[int(j) for j in input().split()]
cnt=[0]*(10**5+10)
for a in A:
    cnt[a]+=1
    cnt[a+1]+=1
    cnt[a+2]+=1
print((max(cnt)))
# Original solution
n=int(eval(input()))
a=list([int(x) for x in input().split()])
ans=0
for i in range(2,100000):
    tmp = a.count(i-1)+a.count(i)+a.count(i+1)
    if ans < tmp:
        ans=tmp
print(ans)

# Optimized solution
n=int(eval(input()))
a=list([int(x) for x in input().split()])
dic={}
for i in a:
    dic[i]=dic.get(i,0)+1
tmp=dic.get(0,0)+dic.get(1,0)
ans=0
for i in range(2,100000):
    tmp+=dic.get(i,0)
    if tmp>ans:
        ans=tmp
    tmp-=dic.get(i-2,0)
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

num = [A.count(A[i]) + A.count(A[i]-1) + A.count(A[i]+1) for i in range(N)]
print((max(num)))

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

maximum = max(A)
count = [0]*(maximum + 2)

for i in range(N):
    if A[i] == 0:
        count[0] += 1
        count[1] += 1
        
    elif A[i] == maximum:
        count[A[i]] += 1
        count[A[i] - 1] += 1
    
    else:
        count[A[i] + 1] += 1
        count[A[i]] += 1
        count[A[i] - 1] += 1

print((max(count)))
# Original solution

N = int(eval(input()))
inlis = list(map(int,input().split()))
donelis =[]
numlis=[]

for i in inlis:
    donelis.append(i+1)
    donelis.append(i)
    donelis.append(i-1)
    if not i in numlis:
        numlis.append(i)
    if not i+1 in numlis:
        numlis.append(i+1)
    if not i-1 in numlis:
        numlis.append(i-1)
estc =0
for i in numlis:
    a =donelis.count(i)
    if estc < a:
        estc = a
print(estc)

# Optimized solution
n = int(eval(input()))
inlis = list(map(int,input().split()))
donelis =[]
numlis=[]

for i in inlis:
    donelis.append(i+1)
    donelis.append(i)
    donelis.append(i-1)

estc =0
donelis.sort()
a = -2
count=0
for i in donelis:
    if a != i:
        if count > estc:
            estc = count
        count = 1
        a = i
    else:
        count +=1
if count >estc:
    estc =count
print(estc)
# Original solution
n = int(eval(input()))
a = list(map(int,input().split()))
    
#dics min max
dicsmin = min(a)
dicsmax = max(a)

counter = []
for i in range(dicsmin,dicsmax + 1):
    xcount = 0
    x = i
    for k in range(len(a)):
        if a[k] == x or a[k] == x-1 or a[k] == x + 1:
            xcount = xcount + 1
    counter.append(xcount)

print((max(counter)))

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
aa = []
amax = max(a) + 100


for i in range(amax + 1):
    aa.append(0)

for i in range(len(a)):
    aa[a[i]] = aa[a[i]] + 1
    
kouho = 1    
for j in range(len(aa) - 2):
    if kouho < aa[j] + aa[j + 1] + aa[j + 2]:
        kouho = aa[j] + aa[j + 1] + aa[j + 2]

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

for i in range(100000):
  B = [j for j in A if i-1 <= j <= i+1]
  if ans < len(B):
    ans = len(B)
    
print(ans)

# Optimized solution
N = int(eval(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)
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split()]
check = [0] * (10**5+1)
check[0] = A.count(0)+A.count(1)

for i in range(1, 10**5+1):
    
    check[i] = check[i-1] - A.count(i-2) + A.count(i+1)
print((max(check)))

# Optimized solution
import bisect

N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
ans = 0
for i in set(A):
    l = bisect.bisect_left(A, i-1)
    r =  bisect.bisect_right(A, i+1)
    ans = max(ans, r-l)
print(ans)
# Original solution
from collections import Counter
N = int(input().strip())
counter = Counter()
for i in list(map(int, input().strip().split(' '))):
  counter += Counter([i-1,i,i+1])

print((counter.most_common(1)[0][1]))

# Optimized solution
from collections import Counter
N = int(input().strip())
counter = Counter()
for i in list(map(int, input().strip().split(' '))):
  counter[i-1] += 1
  counter[i] += 1
  counter[i+1] += 1

print((counter.most_common(1)[0][1]))
# Original solution
import copy
N = int(eval(input()))
a = [int(x) for x in input().split()]
a.sort()
ans = 1
for i in range(len(a)):
  cnt = 1
  b = copy.deepcopy(a)
  rm = a[i]
  b.remove(rm)
  cnt += b.count(rm-1)+b.count(rm+1)
  ans = max(ans, cnt)
print(ans)

# Optimized solution
N = int(eval(input()))
a = [int(x) for x in input().split()]
memo = [0]*(10**5+2)
ans = 1
for i in range(N):
  memo[a[i]] += 1
  memo[a[i]+1] += 1
  memo[a[i]-1] += 1
print((max(memo)))
# Original solution
N = int(eval(input()))
a = list(map(int,input().split()))
amin = min(a)
amax = max(a)
suma = []
for i in range(amin,amax+1):
    sumb = a.count(i) + a.count(i-1) + a.count(i+1)
    suma.append(sumb)
print((max(suma)))

# Optimized solution
import bisect
N = int(eval(input()))
a = sorted(list(map(int,input().split())))
amin = a[0]
amax = a[-1]
suma = []
for i in range(amin,amax+1):
    sumb = bisect.bisect_right(a,i+1) - bisect.bisect_left(a,i-1)
    suma.append(sumb)
print((max(suma)))
# Original solution
import bisect
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
ans = 1

def search(A,a,b):
    import bisect
    ans = bisect.bisect_right(A,b) - bisect.bisect_left(A,a)
    return ans

for i in range(A[-1]+1):
    ans = max(ans,search(A,i-1,i+1))
print(ans)

# Optimized solution
import bisect
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
ans = 1

for i in range(A[-1]+1):
    ans = max(ans,bisect.bisect_right(A,i+1) - bisect.bisect_left(A,i-1))
print(ans)
# Original solution
N = int(eval(input()))
a_lst = [int(x) for x in input().split()]

max_a = -1
max_cnt = -1

for a in a_lst:
    if max_a < a:
        max_a = a
for x in range(max_a + 1):
    cnt = 0
    for a in a_lst:
        if x - 1 <= a and a <= x + 1:
            cnt += 1
    if max_cnt < cnt:
        max_cnt = cnt
print(max_cnt)


# Optimized solution
N = int(eval(input()))
a_lst = [int(x) for x in input().split()]

dict = {}

for a in a_lst:
    if not a - 1 in list(dict.keys()):
        dict[a - 1] = 1
    else:
        dict[a - 1] += 1
    if not a in list(dict.keys()):
        dict[a] = 1
    else:
        dict[a] += 1
    if not a + 1 in list(dict.keys()):
        dict[a + 1] = 1
    else:
        dict[a + 1] += 1
val_lst = list(dict.values())
val_lst.sort(reverse=True)
print((val_lst[0]))
# Original solution
N=int(eval(input()))
A=list(map(int,input().split()))
max_x=max(A)+2
min_x=min(A)-1
l=set()
for x in range(min_x,max_x):
    cnt=0
    for a in A:
        if abs(x-a)<=1:
            cnt+=1
    l.add(cnt)
print((max(l)))

# Optimized solution
N=int(eval(input()))
A=list(map(int,input().split()))
ans=[0]*(max(A)+3)
for a in A:
    ans[a-1]+=1
    ans[a]+=1
    ans[a+1]+=1
print((max(ans)))
# Original solution
n  = int(eval(input()))
ls = list(map(int, input().split()))
ls_plus1  = list([x + 1 for x in ls])
ls_minus1 = list([x - 1 for x in ls])
dic = {}
for a in ls_minus1 + ls + ls_plus1:
    dic[a] = dic.get(a, 0) + 1
print((sorted(dic.values())[-1]))
    

# Optimized solution
n  = int(eval(input()))
ls = list(map(int, input().split()))
ls_plus1  = list([x + 1 for x in ls])
ls_minus1 = list([x - 1 for x in ls])
dic = {}
for a in ls_minus1 + ls + ls_plus1:
    dic[a] = dic.get(a, 0) + 1
print((max(dic.values())))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

a_max = max(A)
a_min = min(A)
dummy = -float("inf")

for x in range(a_min, a_max+1):
    cnt = 0
    A_replace = [l for l in A if l -1 <= x and l + 1 >= x]
    if dummy < len(A_replace):
        dummy = len(A_replace)
        ans = dummy
print(ans)


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

a_max = max(A)
a_min = min(A)

cnt_dict = {}
for i in range(a_min-1, a_max+2):
    cnt_dict[i] = 0
for i in range(len(A)):
    cnt_dict[A[i]-1] += 1
    cnt_dict[A[i]] += 1
    cnt_dict[A[i]+1] += 1

print((max(list(cnt_dict.items()), key = lambda x: x[1])[1]))
# Original solution
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)


# Optimized solution
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)))
# Original solution
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for x in range(min(a), max(a)+1):
  res = c[x] + c[x+1] + c[x-1]
  ans = max(ans, res)
print(ans)

# Optimized solution
n=int(eval(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)))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(1,100001):
    tmp=0
    tmp+=a.count(i-1)
    tmp+=a.count(i)
    tmp+=a.count(i+1)
    if tmp>ans:
        ans=tmp
print(ans)

# Optimized solution
n=int(eval(input()))
b=[0 for i in range(100002)]
a=list(map(int,input().split()))
a.sort()
for i in range(n):
    b[a[i]]+=1
ans=0
for i in range(1,100001):
    tmp=b[i-1]+b[i]+b[i+1]
    if tmp>ans:
        ans=tmp
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(1, 10**5-2):
    if ans < A.count(i) + A.count(i+1) + A.count(i+2):
        ans = A.count(i) + A.count(i+1) + A.count(i+2)
print(ans)

# Optimized solution
def resolve():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    count = [0] * 10 ** 5
    for i in A:
        if i > 1:
            count[i - 1] += 1
        count[i] += 1
        if i < 10**5-1:
            count[i + 1] += 1
    print((max(count)))
resolve()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

m = {}
for a in sorted(set(A)):
	m[a] = A.count(a)

r = 0
for n in m:
	t = m[n]
	if n + 1 in m:
		t += m[n + 1]
	if n + 2 in m:
		t += m[n + 2]
	r = max(r, t)

print(r)


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

m = {}
for a in A:
	if a not in m:
		m[a] = 1
	else:
		m[a] += 1

r = 0
for n in m:
	t = m[n]
	if n + 1 in m:
		t += m[n + 1]
	if n + 2 in m:
		t += m[n + 2]
	r = max(r, t)

print(r)
# Original solution
import collections
N = int(eval(input()))
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
  num = cand_list[i][0]
  count = cand[num]
  if num + 1 in a:
    count += cand[num + 1]
  if num - 1 in a:
    count += cand[num - 1]
  ans = max(ans,count)

print(ans)

# Optimized solution
import collections
N = int(eval(input()))
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
  num = cand_list[i][0]
  count = cand[num] + cand[num + 1] + cand[num - 1]
  ans = max(ans,count)

print(ans)
# Original solution
#import sys
#input = sys.stdin.readline
n=int(eval(input()))
a=[int(i) for i in input().split()]

#print(a)
ans=0
if n==1:
  ans=1
else:
  for i in range(1,100000+1):
    cnt=0
    for j in a:
      if j==i or j==i-1 or j==i+1:
        cnt+=1
      if ans <= cnt:
        ans = cnt

print(ans)


# Optimized solution
from collections import Counter

#tmp_list = [1, 1, 1, 1, 0, 1, 1]


n=int(eval(input()))
a=[int(i) for i in input().split()]
b=[i-1 for i in a]
c=[i+1 for i in a]
d=a+b+c

counter = Counter(d)

print((counter.most_common()[0][1]))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
at=list(set(a))
ans=0
for i in range(len(at)):
  cnt=0
  for j in range(n):
    if a[j]==at[i] or a[j]==at[i]+1 or a[j]==at[i]-1:
      cnt=cnt+1
  ans=max(ans,cnt)
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
temp=[0]*(max(a)+1)
for i in range(n):
  temp[a[i]]=temp[a[i]]+1
ans=0
if max(a)==0 or max(a)==1:
  print(n)
else:
  for i in range(1,max(a)):
    ans=max(ans,temp[i-1]+temp[i]+temp[i+1])
  print(ans)
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
A = []
for i in range(N):
  A.append(a[i]-1)
  A.append(a[i])
  A.append(a[i]+1)
ans = 0
for a in A:
  if ans < A.count(a):
    ans = A.count(a)
print(ans)

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
oldi = 0
m = a[0]
M = 0
ans = 0
if N == 1:
  ans = 1
for i in range(1, N):
  M = a[i]
  while M - m > 2:
    oldi += 1
    m = a[oldi]
  if i - oldi + 1 > ans:
    ans = i - oldi + 1
print(ans)
# Original solution
from collections import Counter

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

A_p1 = [a+1 for a in A]
A_m1 = [a-1 for a in A]

cnt = Counter(A_p1)
cnt += Counter(A)
cnt += Counter(A_m1)

print((max(list(cnt.values()))))

# Optimized solution
import sys
stdin = sys.stdin

def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
a = list(li())

ap = [ai+1 for ai in a]
am = [ai-1 for ai in a]

cnt = Counter(am+a+ap)

print((cnt.most_common(1)[0][1]))
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
B = [0] * len(A)
C = [0] * len(A)
for i in range(len(A)):
  B[i] = A[i] + 1
  C[i] = A[i] - 1

t= 0
m = 0
for X in range(1 ,10 ** 5 + 1):
  t = A.count(X) + B.count(X) + C.count(X)
  m = max(m,t)
print(m)

# Optimized solution
N = int(eval(input()))
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+1)
for a in As:
    nums[a]+=1

for i in range(1,len(nums)):
    if i == len(nums)-1:
        t = nums[i - 1] + nums[i]
    else:
        t = nums[i-1]+nums[i]+nums[i+1]
    c = max(c,t)
print(c)
# Original solution
N = int(eval(input()))
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+1)
for a in As:
    nums[a]+=1

for i in range(1,len(nums)):
    if i == len(nums)-1:
        t = nums[i - 1] + nums[i]
    else:
        t = nums[i-1]+nums[i]+nums[i+1]
    c = max(c,t)
print(c)




# Optimized solution
N = int(eval(input()))
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+2)
for a in As:
    nums[a]+=1

for i in range(1,len(nums)-1):
    t = nums[i-1]+nums[i]+nums[i+1]
    c = max(c,t)
print(c)
# Original solution
from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
cmax = 0
for i in range(N):
    a = A[i]
    ind = bisect_right(A,a+2)
    cmax = max(cmax,ind-i)
print(cmax)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
cmax = 0
for a in A:
    cnt = C[a]
    if a-1 in C:
        cnt += C[a-1]
    if a+1 in C:
        cnt += C[a+1]
    cmax = max(cmax,cnt)
print(cmax)
# Original solution
def main():
  n=eval(input())
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print((max(set(cnt))))   
if __name__=='__main__':
  main()

# Optimized solution
def main():
  import sys
  input = sys.stdin.readline
  n=eval(input())
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print((max(set(cnt))))   
if __name__=='__main__':
  main()
# Original solution
def main():
  import sys
  input = sys.stdin.readline
  n=eval(input())
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print((max(set(cnt))))   
if __name__=='__main__':
  main()

# Optimized solution
def main():
  import sys
  input = sys.stdin.readline
  n=eval(input())
  a=tuple(map(int,input().split()))
  cnt=[0]*(max(a)+3)
  for i in a:
    cnt[i]+= 1
  x,y,z=cnt,cnt[1:],cnt[2:]
  print((max(list(map(sum,list(zip(x,y,z)))))))  
if __name__=='__main__':
  main()
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

a.sort()
cur = a[0]
ans1 = 1
ans = 1

for i in range(n - 1):
    if a[i + 1] - a[i] <= 2:
        cur = a[i]
        ans1 = a.count(cur) + a.count(cur + 1) + a.count(cur + 2)

        if ans < ans1:
            ans = ans1
        ans1 = 0

print(ans)

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

b = [0]*(max_a + 2)

for i in a:
    b[i] += 1

ans = 0
for i in range(max_a + 1):
    tmp = b[i-1] + b[i] + b[i+1]
    ans = max(ans, tmp)

print(ans)
# Original solution

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

    lst = [0 for i in range(n*3)]
    for i in range(n):
        lst[3*i] = a[i]
        lst[3*i+1] = a[i]+1
        lst[3*i+2] = a[i]+2

    ans = -1
    for i in set(lst):
        ans = max(lst.count(i),ans)

    print(ans)



if __name__ == "__main__":
        main()


# Optimized solution

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

    #lst = [0 for i in range(n*3)]
    ans_lst = [0 for i in range(max(a)+4)]
    """
    for i in range(n):
        lst[3*i] = a[i]
        lst[3*i+1] = a[i]+1
        lst[3*i+2] = a[i]+2
    """

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

    """
    ans = -1
    for i in set(lst):
        ans = max(lst.count(i),ans)
    """

    print((max(ans_lst)))


if __name__ == "__main__":
        main()
# Original solution
n = int(eval(input()))
a = [int(x) for x in input().split()]
ans = 0
for x in range(100000):
    cnt = 0
    for elem in a:
        if elem == x-1 or elem == x or elem == x + 1:
            cnt += 1
    ans = max(ans, cnt)
print(ans)


# Optimized solution
n = int(eval(input()))
a = [int(x) for x in input().split()]
counta = [0 for _ in range(100000)]
ans = 0

for elem in a:
    counta[elem] += 1

for x in range(1, 100000 - 1):
    ans = max(ans, counta[x-1] + counta[x] + counta[x+1])

print(ans)
# Original solution
from bisect import*
n = int(eval(input()))
*a,=list(map(int,input().split()))
a.sort()
ans = 0
for i in range(1,10**5):
	ans = max(ans,bisect(a,i+1)-bisect_left(a,i-1))
print(ans)

# Optimized solution
from bisect import*;n,a=open(0);*a,=sorted(map(int,a.split()));print((max(bisect(a,i+1)-bisect(a,i-2) for i in range(10**5))))
# Original solution
from bisect import*;n,a=open(0);*a,=sorted(map(int,a.split()));print((max(bisect(a,i+1)-bisect(a,i-2) for i in range(10**5))))

# Optimized solution
from bisect import*;b=bisect;n,a=open(0);*a,=sorted(map(int,a.split()));print((max(b(a,i)-b(a,i-3)for i in range(10**5))))
# Original solution
from collections import Counter
def solve():
    ans = 0
    N = int(eval(input()))
    A = list(map(int, input().split()))
    c = Counter(A)
    for i in range(1,10**5-1):
        cnt = 0
        if i-1 in c:
            cnt += c[i-1]
        if i in c:
            cnt += c[i]
        if i+1 in c:
            cnt += c[i+1]
        ans = max(ans,cnt)   
    return ans
print((solve()))

# Optimized solution
def solve():
  ans = 0
  N = int(eval(input()))
  A = list(map(int, input().split()))
  lis = [0]*(10**5+2)
  for i in range(N):
    lis[A[i]-1] += 1
    lis[A[i]] += 1
    lis[A[i]+1] += 1
  ans = max(lis)
  return ans
print((solve()))
# Original solution
from collections import Counter

c = Counter()  
N = int(eval(input()))
for x in input().split():
    c[int(x)] += 1

A_uniq = sorted(c.keys())

def gen_candiate(seq):
    s = set()
    for n in seq:
        s.add(n-1)
        s.add(n)
        s.add(n+1)
    return sorted(s)

result = 0
for n in gen_candiate(A_uniq):
    tmp = c.get(n-1, 0) + c.get(n, 0) + c.get(n+1, 0)
    if tmp > result:
        result = tmp

print(result)


# Optimized solution
N=int(eval(input()))
an=sorted(list(map(int,input().split())))
dic={}

for ai in an:
  if ai not in dic:dic[ai]=1
  else:dic[ai]+=1
  pass

max_v=0
for x in range(an[0],an[-1]+1):
  v=0
  if x-1 in dic: v+=dic[x-1]
  if x   in dic: v+=dic[x]
  if x+1 in dic: v+=dic[x+1]
  max_v=max(max_v,v)
print(max_v)
# Original solution
N = int(eval(input()))
a = [int(i) for i in input().split()]
i = 0
b = []
while i <= 100000:
  n = a.count(i)
  b.append(n)
  i += 1
l = len(b)
j = 1
c = []
while j < l-1:
  nn = b[j-1]+b[j]+b[j+1]
  c.append(nn)
  j += 1
print((max(c)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
dic = {}
for nums in A:
  if nums in dic:
    dic[nums] += 1
  else:
    dic[nums] = 1
  if nums-1 in dic:
    dic[nums-1] += 1
  else:
    dic[nums-1] = 1
  if nums+1 in dic:
    dic[nums+1] += 1
  else:
    dic[nums+1] = 1
b = list(dic.values())
print((max(b)))
# Original solution
from collections import Counter

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

C = Counter(A)

ans = 0
for i in range(100000):
    ans = max(C[i] + C[i-1] + C[i+1], ans)

print(ans)


# Optimized solution
from collections import Counter

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

C = Counter(A)

ans = 0
for i in range(max(A)+1):
    ans = max(C[i] + C[i-1] + C[i+1], ans)

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

ans = 0
for X in range(1, 10 ** 5 + 2):
  cnt = 0
  for i in range(N):
    if X - 1 <= A[i] <= X + 1:
      cnt += 1
  ans = max(ans, cnt)
  
print(ans)

# Optimized solution
N = int(eval(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)
# Original solution
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
# 0が混ざってる場合に対応して、１ずつ足しておく
a = [i+1 for i in a]

# 10**5だと99999がコーナーケースになる
l = [0] * 10 ** 6
# いもす法
for i in a:
    l[i-1] += 1
    l[i+2] -= 1

b = accumulate(l)
print((max(list(b))))

# Optimized solution
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
a = [i+1 for i in a]

imos = [0] * (10**5 + 3)

for i in a:
    imos[i-1] += 1
    imos[i+2] -= 1

i = accumulate(imos)
print((max(i)))
# Original solution
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
a = [i+1 for i in a]

imos = [0] * (10**5 + 3)

for i in a:
    imos[i-1] += 1
    imos[i+2] -= 1

i = accumulate(imos)
print((max(i)))


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