

import sys

import collections

#import numpy as np



readline = sys.stdin.readline



def main():

    N = int(eval(input()))

    #A1 = np.array(list(map(int, readline().split())))

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



    count = [0] * (max(A) + 3)

    for a in A:

        count[a+1] += 1

        count[a] += 1

        count[a+2] += 1



    print((max(count)))





if __name__ == "__main__":

    main()

import sys



readline = sys.stdin.readline



def main():

    N = int(eval(input()))

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

    count = [0] * (pow(10, 5)+3)

    for a in A:

        count[a] += 1

        count[a+1] += 1

        count[a+2] += 1

    ans = max(count) 

    print(ans)     





if __name__ == "__main__":

    main()

import sys
import collections

# import numpy as np
readline = sys.stdin.readline


def main():
    N = int(eval(input()))
    # A1 = np.array(list(map(int, readline().split())))
    A = list(map(int, readline().split()))
    count = [0] * (max(A) + 3)
    for a in A:
        count[a + 1] += 1
        count[a] += 1
        count[a + 2] += 1
    print((max(count)))


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.readline


def main():
    N = int(eval(input()))
    A = list(map(int, readline().split()))
    count = [0] * (pow(10, 5) + 3)
    for a in A:
        count[a] += 1
        count[a + 1] += 1
        count[a + 2] += 1
    ans = max(count)
    print(ans)


if __name__ == "__main__":
    main()

-import collections -# import numpy as np -    # A1 = np.array(list(map(int, readline().split()))) -    count = [0] * (max(A) + 3) +    count = [0] * (pow(10, 5) + 3) +        count[a] += 1 -        count[a] += 1 -    print((max(count))) +    ans = max(count) +    print(ans)