#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *a = new int[n];
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]] = 0;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    m[a[i]] = m[a[i]] + 1;
  }
  set<pair<int, int>> s;
  for (auto it = m.begin(); it != m.end(); it++) {
    s.insert(make_pair(it->second, it->first));
  }
  int c = 0;
  int ans = 0;
  while (!s.empty()) {
    pair<int, int> p = *(s.begin());
    if (p.first >= c) {
      ans = ans + ((p.first) - c) * (s.size() - 1);
    }
    s.erase(s.begin());
    c = p.first;
  }
  cout << endl << ans;
}
