import sys input = sys.stdin.readline from collections import * from heapq import * N = int(input()) A = [int(input()) for _ in range(N)] A.sort() pq = [] ans = 0 for Ai in A: if len(pq)>0 and pq[0]+1