from collections import Counter n = int(input().strip()) a = [int(a_temp) for a_temp in input().strip().split(' ')] c = Counter(a) ans = 0 for i, j in zip(sorted(c), sorted(c)[1:]): tmp = c[i] + c[j] if j - i == 1 and tmp > ans: ans = tmp print(max(ans, max(c.values())))