import heapq n = int(input()) a = [int(input()) for i in range(n)] a.sort() hq = [] for i in range(n): if not hq: heapq.heappush(hq, a[i]) else: top = hq[0] if abs(top - a[i]) > 1: heapq.heappop(hq) heapq.heappush(hq, a[i]) else: heapq.heappush(hq, a[i]) print(len(hq))