def main():

    N = int(eval(input()))

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



    c = [0] * (100000 + 1)

    for ai in A:

        c[ai] += 1



    ans = 0

    for i in range(len(c) - 2):

        ans = max(ans, c[i] + c[i+1] + c[i+2])

    print(ans)



if __name__ == "__main__":

    main()
def main():

    N = int(eval(input()))

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



    c = [0] * (100000 + 2)

    for ai in A:

        c[ai+1] += 1

        c[ai] += 1

        c[ai+2] += 1



    print((max(c)))



if __name__ == "__main__":

    main()
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    c = [0] * (100000 + 1)
    for ai in A:
        c[ai] += 1
    ans = 0
    for i in range(len(c) - 2):
        ans = max(ans, c[i] + c[i + 1] + c[i + 2])
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    c = [0] * (100000 + 2)
    for ai in A:
        c[ai + 1] += 1
        c[ai] += 1
        c[ai + 2] += 1
    print((max(c)))


if __name__ == "__main__":
    main()

-    c = [0] * (100000 + 1) +    c = [0] * (100000 + 2) +        c[ai + 1] += 1 -    ans = 0 -    for i in range(len(c) - 2): -        ans = max(ans, c[i] + c[i + 1] + c[i + 2]) -    print(ans) +        c[ai + 2] += 1 +    print((max(c)))