#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, count = 0, sum = 0;
  cin >> n;
  map<int, int> m;
  map<int, int>::iterator it;
  for (int i = 0; i < n; i++) {
    cin >> x;
    m[x]++;
  }
  vector<int> v;
  for (it = m.begin(); it != m.end(); it++) v.push_back((*it).second);
  for (int i = 0; i < v.size() - 1; i++) {
    count += v[i];
    if (count <= v[i + 1]) {
      sum += count;
      count = 0;
    } else {
      sum += v[i + 1];
      count = count - v[i + 1];
    }
  }
  cout << sum << endl;
}
