#include <bits/stdc++.h>
using namespace std;
unordered_map<long long, long long> hm;
void countFreq(long long a[], long long n) {
  for (long long i = 0; i < n; i++) hm[a[i]]++;
  unordered_set<int> s;
  for (long long i = 0; i < n; i++) {
    if (s.find(a[i]) == s.end()) {
      s.insert(a[i]);
    }
  }
}
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int b[n], size = 1, c[n];
  for (int i = 0; i < n; i++) c[i] = 1;
  b[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1])
      b[size++] = a[i];
    else {
      c[size - 1]++;
    }
  }
  int count = 0;
  count += c[0];
  int space = count;
  for (int i = 1; i < n; i++) {
    if (c[i] >= space) {
      count += (c[i] - space);
      space = c[i];
    }
  }
  cout << n - count << endl;
  return 0;
}
