import sys

from collections import defaultdict



cnt = defaultdict(int)



def main():

    n, *a = list(map(int, sys.stdin.read().split()))

    a.sort()

    l = a[0]

    r = a[-1]



    for val in a:

        cnt[val] += 1

    

    ans = 0

    for i in range(l, r+1):

        ans = max(ans, cnt[i-1] + cnt[i] + cnt[i+1])



    print(ans)



if __name__ == '__main__':

    main()
import sys

from collections import defaultdict



n, *a = list(map(int, sys.stdin.read().split()))



def main():

    res = defaultdict(int)

    for i in a:

        res[i-1] += 1

        res[i] += 1

        res[i+1] += 1



    return max(res.values()) 

    

if __name__ == '__main__':

    ans = main()

    print(ans)
import sys
from collections import defaultdict

cnt = defaultdict(int)


def main():
    n, *a = list(map(int, sys.stdin.read().split()))
    a.sort()
    l = a[0]
    r = a[-1]
    for val in a:
        cnt[val] += 1
    ans = 0
    for i in range(l, r + 1):
        ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1])
    print(ans)


if __name__ == "__main__":
    main()

import sys
from collections import defaultdict

n, *a = list(map(int, sys.stdin.read().split()))


def main():
    res = defaultdict(int)
    for i in a:
        res[i - 1] += 1
        res[i] += 1
        res[i + 1] += 1
    return max(res.values())


if __name__ == "__main__":
    ans = main()
    print(ans)

-cnt = defaultdict(int) +n, *a = list(map(int, sys.stdin.read().split())) -    n, *a = list(map(int, sys.stdin.read().split())) -    a.sort() -    l = a[0] -    r = a[-1] -    for val in a: -        cnt[val] += 1 -    ans = 0 -    for i in range(l, r + 1): -        ans = max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]) -    print(ans) +    res = defaultdict(int) +    for i in a: +        res[i - 1] += 1 +        res[i] += 1 +        res[i + 1] += 1 +    return max(res.values()) -    main() +    ans = main() +    print(ans)