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)
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()
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)

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()

-from collections import defaultdict +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) -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()