#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  map<int, int> x;
  map<int, int>::iterator it, it2;
  for (int i = 0; i < n; i++) x[arr[i]]++;
  int ct = 0;
  it = x.begin();
  it2 = x.begin();
  it++;
  for (; it != (x.end()); it++, it2++) {
    ct += min(it->second, it2->second);
    if (it2->second > it->second) it->second += abs(it->second - it2->second);
  }
  cout << ct << endl;
  return 0;
}
