def main():

    _ = int(eval(input()))

    A = [int(i) for i in input().split()]

    from collections import Counter, defaultdict

    c = defaultdict(int)

    for k, v in list(Counter(A).items()):

        c[k] = v

    ans = 0

    for i in range(max(A) + 1):

        if i != 0:

            cur = c[i] + c[i-1] + c[i+1]

        else:

            cur = c[i] + c[i+1]

        ans = max(ans, cur)

    print(ans)





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

    A = [int(i) for i in input().split()]

    max_A = max(A)

    counts = [0] * (max_A + 2)

    for a in A:

        if a > 0:

            counts[a-1] += 1

        counts[a] += 1

        counts[a+1] += 1

    print((max(counts)))





if __name__ == '__main__':

    main()

def main():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    from collections import Counter, defaultdict

    c = defaultdict(int)
    for k, v in list(Counter(A).items()):
        c[k] = v
    ans = 0
    for i in range(max(A) + 1):
        if i != 0:
            cur = c[i] + c[i - 1] + c[i + 1]
        else:
            cur = c[i] + c[i + 1]
        ans = max(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = [int(i) for i in input().split()]
    max_A = max(A)
    counts = [0] * (max_A + 2)
    for a in A:
        if a > 0:
            counts[a - 1] += 1
        counts[a] += 1
        counts[a + 1] += 1
    print((max(counts)))


if __name__ == "__main__":
    main()

-    _ = int(eval(input())) +    N = int(eval(input())) -    from collections import Counter, defaultdict - -    c = defaultdict(int) -    for k, v in list(Counter(A).items()): -        c[k] = v -    ans = 0 -    for i in range(max(A) + 1): -        if i != 0: -            cur = c[i] + c[i - 1] + c[i + 1] -        else: -            cur = c[i] + c[i + 1] -        ans = max(ans, cur) -    print(ans) +    max_A = max(A) +    counts = [0] * (max_A + 2) +    for a in A: +        if a > 0: +            counts[a - 1] += 1 +        counts[a] += 1 +        counts[a + 1] += 1 +    print((max(counts)))