#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<int, int> mp;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    mp[vec[i]]++;
  }
  map<int, int>::iterator it;
  it = mp.begin();
  int sum;
  sum = it->second;
  int c = 0;
  for (; it != mp.end(); ++it) {
    if (it != mp.begin()) {
      if (it->second <= sum)
        c += it->second;
      else {
        c += sum;
        sum = it->second;
      }
    }
  }
  cout << c << endl;
  return 0;
}
