from collections import Counter

def main():

    n = int(eval(input()))

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

    a1 = [i + 1 for i in a]

    a2 = [i - 1 for i in a]

    a = a + a1 + a2

    ac = Counter(a)    

    print((ac.most_common()[0][1]))



if __name__ == '__main__':

    main()

def main():

    n = int(eval(input()))

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

    l1 = [0] * (max(a) + 3)

    for ea in a:

        l1[ea] += 1

        l1[ea+1] += 1

        l1[ea+2] += 1

    print((max(l1)))



if __name__ == '__main__':

    main()
from collections import Counter


def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    a1 = [i + 1 for i in a]
    a2 = [i - 1 for i in a]
    a = a + a1 + a2
    ac = Counter(a)
    print((ac.most_common()[0][1]))


if __name__ == "__main__":
    main()

def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    l1 = [0] * (max(a) + 3)
    for ea in a:
        l1[ea] += 1
        l1[ea + 1] += 1
        l1[ea + 2] += 1
    print((max(l1)))


if __name__ == "__main__":
    main()

-from collections import Counter - - -    a1 = [i + 1 for i in a] -    a2 = [i - 1 for i in a] -    a = a + a1 + a2 -    ac = Counter(a) -    print((ac.most_common()[0][1])) +    l1 = [0] * (max(a) + 3) +    for ea in a: +        l1[ea] += 1 +        l1[ea + 1] += 1 +        l1[ea + 2] += 1 +    print((max(l1)))