from collections import Counter



N = int(eval(input()))

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



A_p1 = [a+1 for a in A]

A_m1 = [a-1 for a in A]



cnt = Counter(A_p1)

cnt += Counter(A)

cnt += Counter(A_m1)



print((max(list(cnt.values()))))
import sys

stdin = sys.stdin



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



from collections import Counter



n = ni()

a = list(li())



ap = [ai+1 for ai in a]

am = [ai-1 for ai in a]



cnt = Counter(am+a+ap)



print((cnt.most_common(1)[0][1]))
from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
A_p1 = [a + 1 for a in A]
A_m1 = [a - 1 for a in A]
cnt = Counter(A_p1)
cnt += Counter(A)
cnt += Counter(A_m1)
print((max(list(cnt.values()))))

import sys

stdin = sys.stdin


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


from collections import Counter

n = ni()
a = list(li())
ap = [ai + 1 for ai in a]
am = [ai - 1 for ai in a]
cnt = Counter(am + a + ap)
print((cnt.most_common(1)[0][1]))

+import sys + +stdin = sys.stdin + + +def li(): +    return list(map(int, stdin.readline().split())) + + +def li_(): +    return [int(x) - 1 for x in stdin.readline().split()] + + +def lf(): +    return list(map(float, stdin.readline().split())) + + +def ls(): +    return stdin.readline().split() + + +def ns(): +    return stdin.readline().rstrip() + + +def lc(): +    return list(ns()) + + +def ni(): +    return int(stdin.readline()) + + +def nf(): +    return float(stdin.readline()) + + -N = int(eval(input())) -A = list(map(int, input().split())) -A_p1 = [a + 1 for a in A] -A_m1 = [a - 1 for a in A] -cnt = Counter(A_p1) -cnt += Counter(A) -cnt += Counter(A_m1) -print((max(list(cnt.values())))) +n = ni() +a = list(li()) +ap = [ai + 1 for ai in a] +am = [ai - 1 for ai in a] +cnt = Counter(am + a + ap) +print((cnt.most_common(1)[0][1]))