import bisect n = int(input()) A = [int(input()) for _ in range(n)] A.sort() sorted_list = [] for x in A: # Find the rightmost value <= x-2 idx = bisect.bisect_right(sorted_list, x - 2) if idx > 0: del sorted_list[idx - 1] bisect.insort(sorted_list, x) print(len(sorted_list))