#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    int k;
    map<int, int> mp;
    vector<int> v;
    for (int i = 0; i < n; i++) {
      scanf("%d", &k);
      ++mp[k];
    }
    map<int, int>::iterator it;
    for (it = mp.begin(); it != mp.end(); it++) v.push_back((*it).second);
    sort(v.begin(), v.end());
    int ans = 0;
    int n = v.size() - 1;
    int last = 0;
    for (int i = 0; i < v.size(); i++) {
      if (n == 0) break;
      ans += n * (v[i] - last);
      last = v[i];
      --n;
      for (int j = i + 1; j < v.size(); j++)
        if (v[j] == v[i]) {
          --n;
          i = j;
        }
    }
    printf("%d\n", ans);
  }
  return 0;
}
