<commit_before>"""
https://www.hackerrank.com/challenges/picking-numbers/problem
"""
n = int(input())
arr = list(map(int, input().split()))

max_value = 1
current_max = 1
print(arr)
arr = sorted(arr)
# print(arr)
for i in range(1, len(arr) - 1):
    if abs(arr[i] - arr[i - 1]) <= 1:
        current_max += 1
    else:
        current_max = 1
    max_value = max(max_value, current_max)

print(max_value)


def trial():
    my_dict = dict()
    for i in arr:
        my_dict[i] = my_dict.setdefault(i, 0) + 1

    maxi = 0
    keys = sorted(my_dict.keys())

    maxi = my_dict[keys[0]]
    current_max = maxi
    for i in range(1, len(keys) - 1):
        print("Key:", i)
        if abs(keys[i] - keys[i - 1]) == 1:<commit_msg>Final<commit_after>"""
https://www.hackerrank.com/challenges/picking-numbers/problem
"""
n = int(input())
arr = list(map(int, input().split()))

max_value = 1
current_max = 1
# print(arr)
arr = sorted(arr)
# print(arr)
t = arr[0]
for i in range(1, len(arr) - 1):
    if abs(arr[i] - t) <= 1:
        current_max += 1
    else:
        t=arr[i]
        current_max = 1
    max_value = max(max_value, current_max)

print(max_value)


def trial():
    my_dict = dict()
    for i in arr:
        my_dict[i] = my_dict.setdefault(i, 0) + 1

    maxi = 0
    keys = sorted(my_dict.keys())

    maxi = my_dict[keys[0]]
    current_max = maxi
    for i in range(1, len(keys) - 1):
        print("Key:", i)
        if abs(keys[i] - keys[i - 1]) == 1:
{'fraction_non_alphanumeric': 0.17177914110429449, 'fraction_numerical': 0.021813224267211998, 'mean_word_length': 2.6608478802992517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2485278', 'n_tokens_mistral': 618, 'n_tokens_neox': 578, 'n_words': 137}