#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  map<int, int> freq;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    freq[arr[i]]++;
  }
  int answer = 0, residue = 0;
  map<int, int>::iterator itr = freq.begin();
  residue = itr->second;
  ++itr;
  for (; itr != freq.end(); itr++) {
    int value = itr->second;
    if (value >= residue) {
      answer += residue;
      residue = value;
    } else {
      answer += value;
    }
  }
  cout << answer;
  return 0;
}
