# Problem C - Together



import collections



# input

N = int(eval(input()))

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



# initialization

num_counter = collections.Counter(a_list)

max_count = 0



# count

for k in list(num_counter.keys()):

    nc = num_counter[k]

    tmp_mae = num_counter[k-1]

    tmp_ushiro = num_counter[k+1]

    max_count = max(max_count, nc + tmp_mae + tmp_ushiro)



# output

print(max_count)

# Problem C - Together



# input

N = int(eval(input()))

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



# initialization

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

max_count = 0



# count

for a in a_nums:

    nums[a] += 1



# max count

for i in range(10**5 + 1):

    if i==0 or i==10**5:

        continue



    tmp_count = nums[i-1] + nums[i] + nums[i+1]

    max_count = max(max_count, tmp_count)



# output

print(max_count)

# Problem C - Together
import collections

# input
N = int(eval(input()))
a_list = list(map(int, input().split()))
# initialization
num_counter = collections.Counter(a_list)
max_count = 0
# count
for k in list(num_counter.keys()):
    nc = num_counter[k]
    tmp_mae = num_counter[k - 1]
    tmp_ushiro = num_counter[k + 1]
    max_count = max(max_count, nc + tmp_mae + tmp_ushiro)
# output
print(max_count)

# Problem C - Together
# input
N = int(eval(input()))
a_nums = list(map(int, input().split()))
# initialization
nums = [0] * (10**5 + 1)
max_count = 0
# count
for a in a_nums:
    nums[a] += 1
# max count
for i in range(10**5 + 1):
    if i == 0 or i == 10**5:
        continue
    tmp_count = nums[i - 1] + nums[i] + nums[i + 1]
    max_count = max(max_count, tmp_count)
# output
print(max_count)

-import collections - -a_list = list(map(int, input().split())) +a_nums = list(map(int, input().split())) -num_counter = collections.Counter(a_list) +nums = [0] * (10**5 + 1) -for k in list(num_counter.keys()): -    nc = num_counter[k] -    tmp_mae = num_counter[k - 1] -    tmp_ushiro = num_counter[k + 1] -    max_count = max(max_count, nc + tmp_mae + tmp_ushiro) +for a in a_nums: +    nums[a] += 1 +# max count +for i in range(10**5 + 1): +    if i == 0 or i == 10**5: +        continue +    tmp_count = nums[i - 1] + nums[i] + nums[i + 1] +    max_count = max(max_count, tmp_count)