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



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



def main():

    m = 10 ** 5

    cnt = [0] * (m + 1)

    for x in a:

        cnt[x] += 1

        if x > 0: cnt[x-1] += 1

        if x < m: cnt[x+1] += 1

    print((max(cnt)))



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

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


def main():
    m = 10**5
    cnt = [0] * (m + 1)
    for x in a:
        cnt[x] += 1
        if x > 0:
            cnt[x - 1] += 1
        if x < m:
            cnt[x + 1] += 1
    print((max(cnt)))


if __name__ == "__main__":
    main()

-from collections import defaultdict -    res = defaultdict(int) -    for i in a: -        res[i - 1] += 1 -        res[i] += 1 -        res[i + 1] += 1 -    return max(res.values()) +    m = 10**5 +    cnt = [0] * (m + 1) +    for x in a: +        cnt[x] += 1 +        if x > 0: +            cnt[x - 1] += 1 +        if x < m: +            cnt[x + 1] += 1 +    print((max(cnt))) -    ans = main() -    print(ans) +    main()