// Arup Guha
// 3/23/2016
// Solution to 2015 December Silver USACO Contest Problem: High Card Wins (highcard).

import java.util.*;
import java.io.*;

public class highcard {

	public static void main(String[] args) throws Exception {

        // Read in Elsie and sort.
		BufferedReader stdin = new BufferedReader(new FileReader("highcard.in"));
		int n = Integer.parseInt(stdin.readLine());
		int[] elsie = new int[n];
		boolean[] used = new boolean[2*n];
		for (int i=0; i<n; i++) {
            elsie[i] = Integer.parseInt(stdin.readLine().trim())-1;
            used[elsie[i]] = true;
		}
		Arrays.sort(elsie);

		// Create sorted bessie array.
		int[] bessie = new int[n];
		int j=0;
		for (int i=0; i<2*n; i++)
            if (!used[i])
                bessie[j++] = i;

        // Stores result and index into Bessie.
        int res = 0;
        j = 0;

        // Go through Elsie's cards, in order from low to high.
        for (int i=0; i<n; i++) {

            // Find smallest possible card to beat Elsie's next card.
            while (j < n && bessie[j] < elsie[i]) j++;

            // Never found it...
            if (j == n) break;

            // Count it and move up bessie's card.
            res++;
            j++;
        }

		// Answer each query by using subtraction on cumulative frequency arrays.
		FileWriter fout = new FileWriter(new File("highcard.out"));
        fout.write(res+"\n");
		fout.close();
	}
}
