from collections import Counter



N = int(eval(input()))

a = Counter(list(map(int, input().split())))#.most_common()

max_total = 0



for i in range(min(a), max(a)+1):

    total = 0

    if i in a:

        total += a[i]

    if i-1 in a:

        total += a[i-1]

    if i+1 in a:

        total += a[i+1]

    max_total = max(max_total, total)

    

print(max_total)
import sys

from collections import Counter



input = sys.stdin.readline



def main():

    N = int(eval(input()))

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

    

    ans = 0

    

    for n, c in list(a.items()): ans = max(ans, c + a[n-1] + a[n+1])

        

    print(ans)



if __name__ == '__main__':

    main()
from collections import Counter

N = int(eval(input()))
a = Counter(list(map(int, input().split())))  # .most_common()
max_total = 0
for i in range(min(a), max(a) + 1):
    total = 0
    if i in a:
        total += a[i]
    if i - 1 in a:
        total += a[i - 1]
    if i + 1 in a:
        total += a[i + 1]
    max_total = max(max_total, total)
print(max_total)

import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    a = Counter(list(map(int, input().split())))
    ans = 0
    for n, c in list(a.items()):
        ans = max(ans, c + a[n - 1] + a[n + 1])
    print(ans)


if __name__ == "__main__":
    main()

+import sys -N = int(eval(input())) -a = Counter(list(map(int, input().split())))  # .most_common() -max_total = 0 -for i in range(min(a), max(a) + 1): -    total = 0 -    if i in a: -        total += a[i] -    if i - 1 in a: -        total += a[i - 1] -    if i + 1 in a: -        total += a[i + 1] -    max_total = max(max_total, total) -print(max_total) +input = sys.stdin.readline + + +def main(): +    N = int(eval(input())) +    a = Counter(list(map(int, input().split()))) +    ans = 0 +    for n, c in list(a.items()): +        ans = max(ans, c + a[n - 1] + a[n + 1]) +    print(ans) + + +if __name__ == "__main__": +    main()