output_description: Print the minimum number of elements that needs to be removed so that a will
  be a good sequence.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_1 a_2 ... a_N
attempt: require 'prime'
  require 'set'
  require 'tsort'
  include Math
  ALP = ('a'..'z').to_a
  INF = 0xffffffffffffffff
  def max(a,b);              a > b ? a : b                              end
  def min(a,b);              a < b ?  a : b                             end
  def swap(a,b);             a, b = b, a                                end
  def gif;                   gets.to_i                                  end
  def gff;                   gets.to_f                                  end
  def gsf;                   gets.chomp                                 end
  def gi;                    gets.split.map(&:to_i)                     end
  def gf;                    gets.split.map(&:to_f)                     end
  def gs;                    gets.chomp.split.map(&:to_s)               end
  def gc;                    gets.chomp.split('')                       end
  def pr(num);               num.prime_division                         end
  def pr?(num);              Prime.prime?(num)                          end
  def digit(num);            num.to_s.length                            end
  def array(s,ini=nil);      Array.new(s){ini}                          end
  def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
  def rep(num);              num.times{|i|yield(i)}                     end
  def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
  
  n = gif
  
  a = gi
  
  b = Hash.new
  a.each do |aa|
  b[aa] ||= 0
  b[aa] += 1
  end
  ans = 0
  b.each do |key,value|
    if value >= key
    ans += value - key
  else
    ans += value
  end
  end
  
  puts ans
  
  
problem_description: Statement
  
  You are given a sequence of positive integers of length N, a = (a_1, a_2, ...,
  a_N). Your objective is to remove some of the elements in a so that a will be
  a **good sequence**.
  
  Here, an sequence b is a **good sequence** when the following condition holds
  true:
  
    * For each element x in b, the value x occurs exactly x times in b.
  
  For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are
  good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not.
  
  Find the minimum number of elements that needs to be removed so that a will be
  a good sequence.
samples: [{"input": "4\n    3 3 3 3", "output": "1\n    \n\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good\nsequence.\n\n* * *"}, {"input": "5\n    2 4 1 4 2", "output": "2\n    \n\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good\nsequence.\n\n* * *"}, {"input": "6\n    1 2 2 3 3 3", "output": "0\n    \n\n* * *"}, {"input": "1\n    1000000000", "output": "1\n    \n\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\n* * *"}, {"input": "8\n    2 7 1 8 2 8 1 8", "output": "5"}]