CodeEff/ECCO huggingface dataset:
# Original solution
N=int(eval(input()))
ANi=input().split()
AN=list(map(int,ANi))


Xhairetsu={}


for i in range(len(AN)):
    for X in range(1,10**5):
        if AN[i]<=X+1 and AN[i]>=X-1 and X  not in list(Xhairetsu.keys()):
            Xhairetsu[X]=1
        elif AN[i]<=X+1 and AN[i]>=X-1 and X in list(Xhairetsu.keys()):
            Xhairetsu[X]+=1
        
print((max(Xhairetsu.values())))

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

Whairetsu={}
Xhairetsu={}
Yhairetsu={}


for i in range(len(AN)):
    if AN[i] not in list(Xhairetsu.keys()):
        Xhairetsu[AN[i]]=1
    elif AN[i] in list(Xhairetsu.keys()):
        Xhairetsu[AN[i]]+=1
    
    if AN[i] -1 not in list(Whairetsu.keys()):
        Whairetsu[AN[i]-1]=1
    elif AN[i]-1 in list(Whairetsu.keys()):
        Whairetsu[AN[i]-1]+=1
    
    if AN[i] +1 not in list(Yhairetsu.keys()):
        Yhairetsu[AN[i]+1]=1
    elif AN[i]+1 in list(Yhairetsu.keys()):
        Yhairetsu[AN[i]+1]+=1
    


anshairetsu={}
for i in range(10**5+1):
    if i in list(Whairetsu.keys()):
        if i in list(anshairetsu.keys()):
            anshairetsu[i]+=Whairetsu[i]
        else:
            anshairetsu[i]=Whairetsu[i]
            
    if i in list(Xhairetsu.keys()):
        if i in list(anshairetsu.keys()):
            anshairetsu[i]+=Xhairetsu[i]
        else:
            anshairetsu[i]=Xhairetsu[i]
            
    if i in list(Yhairetsu.keys()):
        if i in list(anshairetsu.keys()):
            anshairetsu[i]+=Yhairetsu[i]
        else:
            anshairetsu[i]=Yhairetsu[i]
print((max(anshairetsu.values())))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(set(a))
l=[];m=[]
for i in range(len(b)):
  l.append([b[i],a.count(b[i])])
if len(l)>2:
  for j in range(len(b)-2):
    x=l[j][1]
    if l[j+1][0]-l[j][0]<=2:
      x+=l[j+1][1]
      if l[j+2][0]-l[j][0]<=2:x+=l[j+2][1]
    m.append(x)
elif len(l)>1:
  for j in range(len(b)-1):
    x=l[j][1]
    if l[j+1][0]-l[j][0]<=2:x+=l[j+1][1]
    m.append(x)
else:
  m.append(l[0][1])
print((max(m)))

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
l=[]
for i in range(max(a)+3):
  l.append(0)
for j in range(n):
  l[a[j]+1]+=1
m=[]
for i in range(1,max(a)+2):
  m.append(l[i-1]+l[i]+l[i+1])
print((max(m)))
# Original solution
nums = int(eval(input()))
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in range(100005):
    ary_count[i] = ary.count(i)

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)

# Optimized solution
nums = int(eval(input()))
ary  = list(map(int,input().split()))
count =0
max_count = 0
ary.sort()
ary_count = [0 for i in range(100005)]
ary_count.append(0)

for i in ary:
    ary_count[i] += 1

for i in range(1,100005):
    count += ary_count[i]
    count += ary_count[i+1]
    count += ary_count[i-1]
    if count > max_count:
        max_count = count
    count = 0
print(max_count)
# Original solution
n = int(eval(input()))

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

nums = [0] * (10**5+1)
nums[0] = a.count(0) + a.count(1)
nums[(10**5)] = a.count((10**5)-1) + a.count((10**5))
for i in range(1, (10**5)):
  nums[i] = a.count(i-1) + a.count(i) + a.count(i+1)
  
print((max(nums)))

# Optimized solution
n = int(eval(input()))

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

d = {}

for i in a:
  for j in range(i - 1, i + 2): #aの値の両隣まで
    d[j] = d.get(j, 0) + 1#getは第一引数で指定したキーがなかったら第二引数で指定した値を戻す
    
    
print((max(d.values())))
# Original solution
N = int(eval(input()))
a = []
elements = set()
for i in input().split():
    a.append(int(i))
    elements.add(int(i))
    elements.add(int(i)-1)
    elements.add(int(i)+1)
max_count = 0
for X in elements:
    count = 0
    for num in a:
        if X-1 <= num <= X+1:
            count += 1
    max_count = max(max_count, count)
print(max_count)

# Optimized solution
def dic_counter(dic, num):
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

N = int(eval(input()))
dic = {}
for i in input().split():
    dic_counter(dic, int(i)-1)
    dic_counter(dic, int(i))
    dic_counter(dic, int(i)+1)
for _, value in sorted(list(dic.items()), key=lambda x: -x[1]):
    print(value)
    break
# Original solution
def dic_counter(dic, num):
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

N = int(eval(input()))
dic = {}
for i in input().split():
    dic_counter(dic, int(i)-1)
    dic_counter(dic, int(i))
    dic_counter(dic, int(i)+1)
for _, value in sorted(list(dic.items()), key=lambda x: -x[1]):
    print(value)
    break

# Optimized solution
def dic_counter(dic, num):
    if num in dic:
        dic[num] += 1
    else:
        dic[num] = 1

_ = int(eval(input()))
dic = {}
for i in input().split():
    dic_counter(dic, int(i)-1)
    dic_counter(dic, int(i))
    dic_counter(dic, int(i)+1)
print((sorted(list(dic.values()), key=lambda x: -x)[0]))
# Original solution
from collections import Counter
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a1 = [i + 1 for i in a]
    a2 = [i - 1 for i in a]
    a = a + a1 + a2
    ac = Counter(a)    
    print((ac.most_common()[0][1]))

if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    l1 = [0] * (max(a) + 3)
    for ea in a:
        l1[ea] += 1
        l1[ea+1] += 1
        l1[ea+2] += 1
    print((max(l1)))

if __name__ == '__main__':
    main()
# Original solution
from collections import Counter

N = int(eval(input()))
As = list(map(int, input().split()))
box = []

for a in As:
    box.append(a)
    box.append(a+1)
    box.append(a-1)
    
cnt = Counter(box).most_common(1)
print((cnt[0][1]))

# Optimized solution
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
B = []
for a in A:
    B.append(a)
    B.append(a-1)
    B.append(a+1)

C = Counter(B).most_common(1)
print((C[0][1]))
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
a.sort()
count = 0
ans = []
for i in range(n):
  for j in range(n-1):
    if j >= i and a[j]-a[i] <= 2:
      #print(i,j)
      count += 1
    else:
      ans.append(count)
      count = 0
if n == 1:
  print((1))
else:
  print((max(ans)))

# Optimized solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
a.sort()
count = 0
p1 = []
for i in range(n):
  p1.append(a[i]-1)
p2 = []
for i in range(n):
  p2.append(a[i]+1)
chk = a+p1+p2
chk.sort()
#print(chk)
ans =[]
count = 0
for i in range(3*n-1):
  if chk[i+1] == chk[i]:
    count += 1
  else:
    ans.append(count)
    count = 0
print((max(ans)+1))
# Original solution
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    d=dict()
    for i in range(n):
        if a[i] not in d:
            d[a[i]]=1
        else:
            d[a[i]]+=1

    cnt=0
    for x in range(1,10**5+1):
        if x-1 in d: s=d[x-1]
        else: s=0

        if x in d: t=d[x]
        else: t=0

        if x+1 in d: u=d[x+1]
        else: u=0

        cnt=max(cnt,s+t+u)

    print(cnt)

if __name__=="__main__":
    main()

# Optimized solution
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    li=[0]*(10**5+2)
    for i in range(n):
        li[a[i]]+=1

    cnt=0
    for x in range(1,10**5+1):
        cnt=max(cnt,li[x-1]+li[x]+li[x+1])

    print(cnt)

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

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

for a in al:
    num[a] += 1

ans = 0
for i in range(10**5+2):
    x_cnt = sum(num[i-1:i+2])
    ans = max(ans, x_cnt)

print(ans)

# Optimized solution
n = int(eval(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)))
# Original solution
from collections import Counter as C

n  =  int(eval(input()))
a= list(input().split())
al = list([int(i) for i in a])
aset = set([int(i) for i in a])

cnt=0

#print(C(al)[0])
for i in aset:
  #print(i)
  #print(al.count(i-1),al.count(i),al.count(i+1))
  if cnt < C(al)[i-1] + C(al)[i] + C(al)[i+1]:
    cnt = C(al)[i-1] + C(al)[i] + C(al)[i+1]

print(cnt)

# Optimized solution
from collections import Counter as C

n  =  int(eval(input()))
a= list(input().split())
al = list([int(i) for i in a])
aset = set([int(i) for i in a])

cnt=0
ca = C(al)
#print(C(al)[0])
for i in aset:
  #print(i)
  #print(al.count(i-1),al.count(i),al.count(i+1))
  if cnt < ca[i-1] + ca[i] + ca[i+1]:
    cnt = ca[i-1] + ca[i] + ca[i+1]

print(cnt)
# Original solution
from collections import Counter

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

min_v=min(a)
max_v=max(a)

c=Counter(a)

ans=0
for i in range(min_v,max_v+1):
  t_ans=c[i-1]+c[i]+c[i+1]
  ans=max(ans,t_ans)

print(ans)

# Optimized solution
from sys import stdin
nii=lambda:list(map(int,stdin.readline().split()))
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

n=int(eval(input()))
a=lnii()

c=Counter(a)
a_max=max(a)

ans=0
for i in range(a_max+1):
  t_ans=c[i-1]+c[i]+c[i+1]
  ans=max(ans,t_ans)

print(ans)
# Original solution
import collections

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

dict = collections.Counter(a)

#print(n)
#print(a)
#print(dict)
#print(dic[str(1)])

x_max = 0
mem_key = ""

for key in list(dict.keys()):
  k = int( key )
  l = dict[str(k-1)]
  m = dict[str(k)]
  n = dict[str(k+1)]
  #print(k,m,l,n)
  #print(l+m+n)
  if l+m+n >= x_max:
    x_max = l+m+n
    mem_key = key
    
print(x_max)
#print(mem_key)

# Optimized solution
import collections

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

dict = collections.Counter(a)

x_max = 0
#mem_key = ""

for key in list(dict.keys()):
  k = int( key )
  x_max = max(x_max, dict[str(k-1)]+dict[str(k)]+dict[str(k+1)])

    
print(x_max)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
t = [1 if a[i] == a[j] or abs(a[i] - a[j]) == 1 else 0 for i in range(n) for j in range(n)]
print((max([sum(t[i:i+n]) for i in range(0, len(t), n)])))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
count = {}
for i in a:
  for j in [-1, 0, 1]:
    count.setdefault(i+j, 0)
    count[i+j] += 1
  
print((max(count.values())))
# Original solution
n = int(eval(input()))
a = input().split()
a = list(map(int,a))

arr = []
for x in range(10**5):
    count = 0
    for i in range(n):
        if a[i] == x-1 or a[i] == x or a[i] == x+1:
            count += 1
    arr.append(count)

print((max(arr)))


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

arr = [0] * (10**5 + 2)
for i in range(n):
    arr[a[i]] += 1
ans = []
for x in range(1,10**5):
    ans.append(arr[x-1] + arr[x] + arr[x+1])

print((max(ans)))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0]*(10**7)
for i in a:
    cnt[i-1] += 1
    cnt[i] += 1
    cnt[i+1] += 1
print((max(cnt)))

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0]*(10**6)
for i in a:
    cnt[i-1] += 1
    cnt[i] += 1
    cnt[i+1] += 1
print((max(cnt)))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0]*(10**6)
for i in a:
    cnt[i-1] += 1
    cnt[i] += 1
    cnt[i+1] += 1
print((max(cnt)))

# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
cnt = [0]*(10**5+2)
for i in a:
    cnt[i-1] += 1
    cnt[i] += 1
    cnt[i+1] += 1
print((max(cnt)))
# Original solution
from collections import Counter
N = int(eval(input()))
a = list(map(int,input().split()))
counter = Counter(a)
ans=[]
for k,v in list(counter.items()):
    if k-1 in counter:
        v+=counter[k-1]
    if k+1 in counter:
        v+=counter[k+1]
    ans.append(v)
print((max(ans)))

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
c = [0] * (max(a)+3)
for v in a:
    c[v] += 1
    c[v+1] += 1
    c[v+2] += 1
print((max(c)))
# Original solution

import sys
import collections
#import numpy as np

readline = sys.stdin.readline

def main():
    N = int(eval(input()))
    #A1 = np.array(list(map(int, readline().split())))
    A = list(map(int, readline().split()))

    count = [0] * (max(A) + 3)
    for a in A:
        count[a+1] += 1
        count[a] += 1
        count[a+2] += 1

    print((max(count)))


if __name__ == "__main__":
    main()


# Optimized solution
import sys

readline = sys.stdin.readline

def main():
    N = int(eval(input()))
    A = list(map(int, readline().split()))
    count = [0] * (pow(10, 5)+3)
    for a in A:
        count[a] += 1
        count[a+1] += 1
        count[a+2] += 1
    ans = max(count) 
    print(ans)     


if __name__ == "__main__":
    main()
# Original solution
n,*l=list(map(int,open(0).read().split()))
c=[0]*(10**5+3)
for i in l:
  for j in (-1,0,1): c[i+j]+=1
print((max(c)))

# Optimized solution
eval(input())
c=[0]*100002
for i in map(int,input().split()):
  for j in (0,1,2): c[i+j]+=1
print((max(c)))
# Original solution
eval(input())
A=list(map(int,input().split()))
B=set(A)
dict={}
for x in B:
  dict[x]=A.count(x)
max=0
for x in B:
  tmp = dict[x]
  if x-1 in B:
    tmp+=dict[x-1]
  if x+1 in B:
    tmp+=dict[x+1]
  if tmp>max:
    max=tmp
print(max)

# Optimized solution
n = int(eval(input()))
A = list(map(int,input().split()))
Ap = [a+1 for a in A]
Am = [a-1 for a in A]
label = set(A+Ap+Am)
dict = {l:0 for l in label}
for a in A+Ap+Am:
    dict[a]+=1
print((max(dict.values())))
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
count=0
a_plus=[]
a_minu=[]
for i in range(n):
    a_plus.append(a[i]+1)
    a_minu.append(a[i]-1)
import collections
a.extend(a_plus)
a.extend(a_minu)
data=collections.Counter(a)
data=sorted(list(data.items()),key=lambda x:x[1],reverse=True)
print((data[0][1]))


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
from collections import Counter
plus=[0]*n
minus=[0]*n
for i in range(n):
    plus[i]=a[i]+1
    minus[i]=a[i]-1
plus=plus+minus+a
data=Counter(plus)
ans=[]
for i in list(data.values()):
    ans.append(i)
print((max(ans)))
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
L = [0] * 10 ** 5
for i in range(N):
    L[a[i]] += 1
s = L[0] + L[1] + L[2]
A = s
for i in range(10 ** 5-3):
    s += L[i+3] - L[i]
    A = max(A,s)
print(A)


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

num_list = [0 for _ in range(10 ** 5)]
for i in a:
    if i > 0:
        num_list[i - 1] += 1
    num_list[i] += 1
    if i < 10 ** 5 - 1:
        num_list[i + 1] += 1
print((max(num_list)))
# Original solution
import collections

num = int(eval(input()))
s = sorted(list(map(int, input().split())))
if num == 1:
    print((1))
else:
    max_ans = 0
    for i in range(num):
        start = s[i]
        c = collections.Counter(s)
        current_ans = c[start]+c[start+1]+c[start+2]
        max_ans = max(current_ans,max_ans)
        i += c[start]
    print(max_ans) 

# Optimized solution
import collections

num = int(eval(input()))
s = sorted(list(map(int, input().split())))
if num == 1:
    print((1))
else:
    c = collections.Counter(s)
    max_ans = 0
    for i in range(num):
        start = s[i]
        current_ans = c[start]+c[start+1]+c[start+2]
        max_ans = max(current_ans,max_ans)
        i += c[start]
    print(max_ans)
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
i = 0
max_count = 0
count = 0
while i < len(a):
    x = a[i]
    j = i
    while j < len(a):
        if x == a[j] or x+1 == a[j] or x+2 == a[j]:
            count += 1
            j += 1
        else:
            break
    if max_count < count:
        max_count = count
    count = 0
    i += 1
print(max_count)


# Optimized solution
N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
max_count = 0
count = 0
i = 0
x_before = -1
while i < N:
    x = a[i]
    j = i
    if x_before != x:
        while j < len(a):
            if x == a[j] or x+1 == a[j] or x+2 == a[j]:
                count += 1
                j += 1
            else:
                break
        if max_count < count:
            max_count = count
    x_before = x
    count = 0
    i += 1
print(max_count)
# Original solution
N = int(eval(input()))
A = [int(i) for i in input().split(' ')]
count = 0
answer = 0

A.sort()

for i in range(A[0],A[N-1]+1):
    count = 0
    for a in A:
        if i-1 <= a <= i+1:
            count += 1
    if answer < count:
        answer = count
print(answer)

# Optimized solution
N = int(eval(input()))
A = [int(i) for i in input().split(' ')]
A.sort()
B = [0]*(A[N-1]+3)

for a in A:
    B[a] += 1
    B[a+1] += 1
    B[a+2] += 1

print((max(B)))
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

ys = [0] * (max(a)+ 1)

for x in range(len(ys)):
    y = a.count(x-1) + a.count(x) + a.count(x+1)
    ys[x] = y

print((max(ys)))

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

d = {}

for i in range(max(a)+1):
  d[i] = 0

for a_ in a:
  d[a_] += 1

d[-1] = 0
d[max(a)+1] = 0

ans = 0

for x in range(max(a)+1):
  if x-1 in d:
    ans = max(ans, d[x-1] + d[x] + d[x+1])

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

nums = [0]*(10**5+1)
for i in a: nums[i] += 1

t = sum(nums[:3])
ans = t
for i in range(3,10**5+1):
  t = t - nums[i-3] + nums[i]
  if ans < t: ans = t
print(ans)

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

nums = [0]*(max(a)+1)
for i in a: nums[i] += 1
ans = sum(nums[:3])
t = sum(nums[:3])
for i in range(len(nums)-3):
  t = t + nums[i+3] - nums[i]
  if ans < t: ans = t
print(ans)
# Original solution
N = int(eval(input()))
a = list(map(int, input().split()))

b = []

for i in range(100000):
    b.append(a.count(i-1) + a.count(i) + a.count(i+1))

print((max(b)))


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

b = []
c = []
for i in range(N):
    if a[i] > 0:
        b.append(a[i] - 1)
        c.append(a[i] + 1)
    else:
        c.append(a[i] + 1)

abc = a + b + c
count = [0] * (max(abc) + 1)

for x in abc:
    count[x] += 1

print((max(count)))
# Original solution
# encoding: "utf-8"

from collections import defaultdict

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 first_count_and_pop(xs):
    cnt = 0
    fst = xs[0]
    # cnt = xs.count(fst)
    for x in xs:
        if x != fst:
            break
        cnt += 1
    return (cnt, xs[cnt:])    
    

def main():
    _ = eval(input())
    xs = Stdin.read_line(converter=int)
    xs.sort()
    ys = defaultdict(int)
    while xs:
        key = xs[0]
        cnt, xs = first_count_and_pop(xs)
        ys[key] += cnt
        ys[key-1] += cnt
        ys[key+1] += cnt

    print((max(ys.values())))

# def main_():
#     input()
#     xs = Stdin.read_line(converter=int)
#     xs.sort()
#     counts = list()
#     for i in range(100000):
#         if not xs:
#             counts.extend([0] * (100000 - len(counts)))
#             break     
#         elif i == xs[0]:
#             cnt, xs = first_count_and_pop(xs)
#             counts.append(cnt)
#         else:
#             counts.append(0)
#     m = 0
#     for i in range(0, 100000):
#         if i == 0:
#             temp = counts[i] + counts[i+1]
#         elif i == 100000 - 1:
#             temp = counts[i-1] + counts[i]
#         else:
#             temp = counts[i-1] + counts[i] + counts[i+1]
#         if m < temp:
#             m = temp
#     print(m)

if __name__ == "__main__":
    main()

# Optimized solution
eval(input())
a_list = [int(s) for s in input().split()]

count = [0]*100002

for a in a_list:
    count[a] += 1
    count[a+1] += 1
    count[a+2] += 1
    
print((max(count)))
# Original solution
# encoding: "utf-8"

from collections import defaultdict

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 count_and_del(xs):
    cnt = 0
    fst = xs[-1]
    for x in reversed(xs):
        if x != fst:
            break
        cnt += 1
    del xs[-cnt:]
    return cnt   


def main():
    _ = eval(input())
    xs = Stdin.read_line(converter=int)
    xs.sort(reverse=True)
    ys = defaultdict(int)
    while xs:
        key = xs[-1]
        cnt = count_and_del(xs)
        ys[key] += cnt
        ys[key-1] += cnt
        ys[key+1] += cnt

    print((max(ys.values())))


if __name__ == "__main__":
    main()


# Optimized solution
# encoding: "utf-8"

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 count_and_drop(xs):
    cnt = 0
    fst = xs[-1]
    for x in reversed(xs):
        if x != fst:
            break
        cnt += 1
    del xs[-cnt:]
    return cnt


def main():
    _ = eval(input())
    xs = Stdin.read_line(converter=int)
    xs.sort()
    ys = dict()
    while xs:
        key = xs[-1]
        cnt = count_and_drop(xs)
        ys[key] = cnt
    m = 0
    for x in list(ys.keys()):
        temp = ys.get(x-1, 0) + ys.get(x, 0) + ys.get(x+1, 0)
        if m < temp:
            m = temp
    print(m)

if __name__ == "__main__":
    main()