#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp, counter = 0, b[1001] = {0}, cMin, lMin = 0, aMax = 0;
  cin >> n;
  vector<int> dis;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    b[temp]++;
  }
  for (int i = 0; i < 1001; i++) {
    if (b[i] > 0) dis.push_back(b[i]);
    if (b[i] > aMax) aMax = b[i];
  }
  while (dis.size() > 0) {
    cMin = aMax;
    for (int i = 0; i < dis.size(); i++) {
      if (dis[i] == lMin)
        dis.erase(dis.begin() + i);
      else if (dis[i] < cMin)
        cMin = dis[i];
    }
    counter += (dis.size() - 1) * (cMin - lMin);
    lMin = cMin;
  }
  cout << counter;
  return 0;
}
