from collections import Counter input() N = Counter(map(int, raw_input().split())) ans = 0 for num in N: # print num big = N.get(num + 1, 0) small = N.get(num - 1, 0) cnt = big if big > small else small total = cnt + N[num] # print total, cnt ans = total if total > ans else ans print ans