#include <bits/stdc++.h>
using namespace std;
long long a[1000050];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long rec = 0;
  long long num = a[0];
  long long have = 0;
  long long can = 0;
  for (int i = 0; i < n; i++) {
    if (num == a[i]) have++;
    if (num != a[i]) {
      can++;
      if (a[i + 1] != a[i]) {
        num = a[i];
        rec += min(have, can);
        have = have + can - min(have, can);
        can = 0;
      }
    }
  }
  rec = n - have;
  cout << rec << endl;
}
