#include <bits/stdc++.h>
using namespace std;
int freq[1002] = {};
int main() {
  int n;
  cin >> n;
  for (int i = 1, a; i <= n; ++i) {
    cin >> a;
    ++freq[a];
  }
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  priority_queue<pair<int, int>> pq;
  for (int i = 1; i <= 1000; ++i)
    if (freq[i] != 0) pq.push(make_pair(-i, freq[i]));
  int total = 0;
  vector<pair<int, int>> temp;
  int counter = 0;
  while (1) {
    pair<int, int> p1 = pq.top();
    pair<int, int> p2;
    pq.pop();
    --p1.second;
    ++counter;
    if (p1.second > 0) temp.push_back(p1);
    if (pq.empty()) {
      total += counter - 1;
      counter = 0;
      if (temp.size() <= 1) break;
      for (int k = 0; k < temp.size(); ++k) {
        pq.push(temp[k]);
      }
      temp.clear();
    }
  }
  cout << total << endl;
  return 0;
}
