n = int(eval(input()))

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

dict = {}

ans = 0



for i in range(n):

  if a[i] not in dict:

    dict[a[i]] = 1

  else:

    dict[a[i]] += 1



l = sorted(dict.items())

l += [(-1,0),(-2,0)]



for j in range(len(l)-2):

  if l[j][0]+1 == l[j+1][0] and l[j][0]+2 == l[j+2][0]:

     ans = max(ans,l[j][1]+l[j+1][1]+l[j+2][1])

  elif l[j][0]+1 == l[j+1][0] and l[j][0]+2 != l[j+2][0]:

     ans = max(ans,l[j][1]+l[j+1][1])

  elif l[j][0]+1 != l[j+1][0] and l[j][0]+2 != l[j+2][0]:

     ans = max(ans,l[j][1])

   

  

print(ans)

  
n = int(eval(input()))

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

ans = 0



l = [0]*100001



for i in a:

  l[i] += 1



for i in range(len(l)-2):

  ans = max(ans,l[i]+l[i+1]+l[i+2])

  

print(ans)

  
n = int(eval(input()))
a = list(map(int, input().split()))
dict = {}
ans = 0
for i in range(n):
    if a[i] not in dict:
        dict[a[i]] = 1
    else:
        dict[a[i]] += 1
l = sorted(dict.items())
l += [(-1, 0), (-2, 0)]
for j in range(len(l) - 2):
    if l[j][0] + 1 == l[j + 1][0] and l[j][0] + 2 == l[j + 2][0]:
        ans = max(ans, l[j][1] + l[j + 1][1] + l[j + 2][1])
    elif l[j][0] + 1 == l[j + 1][0] and l[j][0] + 2 != l[j + 2][0]:
        ans = max(ans, l[j][1] + l[j + 1][1])
    elif l[j][0] + 1 != l[j + 1][0] and l[j][0] + 2 != l[j + 2][0]:
        ans = max(ans, l[j][1])
print(ans)

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

-dict = {} -for i in range(n): -    if a[i] not in dict: -        dict[a[i]] = 1 -    else: -        dict[a[i]] += 1 -l = sorted(dict.items()) -l += [(-1, 0), (-2, 0)] -for j in range(len(l) - 2): -    if l[j][0] + 1 == l[j + 1][0] and l[j][0] + 2 == l[j + 2][0]: -        ans = max(ans, l[j][1] + l[j + 1][1] + l[j + 2][1]) -    elif l[j][0] + 1 == l[j + 1][0] and l[j][0] + 2 != l[j + 2][0]: -        ans = max(ans, l[j][1] + l[j + 1][1]) -    elif l[j][0] + 1 != l[j + 1][0] and l[j][0] + 2 != l[j + 2][0]: -        ans = max(ans, l[j][1]) +l = [0] * 100001 +for i in a: +    l[i] += 1 +for i in range(len(l) - 2): +    ans = max(ans, l[i] + l[i + 1] + l[i + 2])