#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i;
  cin >> n;
  unordered_map<long long, long long> mp;
  for (i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    mp[temp]++;
  }
  long long sum = 0;
  vector<long long> v;
  for (auto it : mp) {
    v.push_back(it.second);
  }
  sort(v.begin(), v.end());
  long long val = 0;
  for (i = 0; i < v.size(); i++) {
    long long temp = (v.size() - 1 - i) * (v[i] - val);
    if (temp > 0) sum += temp;
    val = v[i];
  }
  cout << sum << endl;
}
