# vim: set fileencoding=utf-8:

from collections import Counter





def main():

    N = eval(input())

    a = [int(ele) for ele in input().split()]

    a_plus = [ele + 1 for ele in a]

    a_minus = [ele - 1 for ele in a]

    ct = Counter(a)

    ct_plus = Counter(a_plus)

    ct_minus = Counter(a_minus)



    for k, v in list(ct_plus.items()):

        ct[k] += v



    for k, v in list(ct_minus.items()):

        ct[k] += v



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





if __name__ == "__main__":

    main()

import collections





def main():

    N = int(eval(input()))

    a = [0] * (N * 3)

    i = 0

    for ele in input().split():

        ele = int(ele)

        a[i] = ele-1

        i += 1

        a[i] = ele

        i += 1

        a[i] = ele+1

        i += 1



    ctr = collections.Counter(a)

    print((max(list(ctr.values()))))





if __name__ == "__main__":

    main()

# vim: set fileencoding=utf-8:
from collections import Counter


def main():
    N = eval(input())
    a = [int(ele) for ele in input().split()]
    a_plus = [ele + 1 for ele in a]
    a_minus = [ele - 1 for ele in a]
    ct = Counter(a)
    ct_plus = Counter(a_plus)
    ct_minus = Counter(a_minus)
    for k, v in list(ct_plus.items()):
        ct[k] += v
    for k, v in list(ct_minus.items()):
        ct[k] += v
    print((ct.most_common()[0][1]))


if __name__ == "__main__":
    main()

import collections


def main():
    N = int(eval(input()))
    a = [0] * (N * 3)
    i = 0
    for ele in input().split():
        ele = int(ele)
        a[i] = ele - 1
        i += 1
        a[i] = ele
        i += 1
        a[i] = ele + 1
        i += 1
    ctr = collections.Counter(a)
    print((max(list(ctr.values()))))


if __name__ == "__main__":
    main()

-# vim: set fileencoding=utf-8: -from collections import Counter +import collections -    N = eval(input()) -    a = [int(ele) for ele in input().split()] -    a_plus = [ele + 1 for ele in a] -    a_minus = [ele - 1 for ele in a] -    ct = Counter(a) -    ct_plus = Counter(a_plus) -    ct_minus = Counter(a_minus) -    for k, v in list(ct_plus.items()): -        ct[k] += v -    for k, v in list(ct_minus.items()): -        ct[k] += v -    print((ct.most_common()[0][1])) +    N = int(eval(input())) +    a = [0] * (N * 3) +    i = 0 +    for ele in input().split(): +        ele = int(ele) +        a[i] = ele - 1 +        i += 1 +        a[i] = ele +        i += 1 +        a[i] = ele + 1 +        i += 1 +    ctr = collections.Counter(a) +    print((max(list(ctr.values()))))