def main():

    _ = int(eval(input()))

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

    A.sort()

    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(10**5+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():

    _ = 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():
    _ = int(eval(input()))
    A = [int(i) for i in input().split()]
    A.sort()
    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(10**5 + 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():
    _ = 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()

-    A.sort() -    for i in range(10**5 + 1): +    for i in range(max(A) + 1):