n = int(input()) a = sorted([int(input()) for i in range(n)]) idx = 0 ans = 0 for i in range(n): while a[i] >= a[idx] + 2: idx += 1 ans = max(ans, i - idx + 1) print(ans)