#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n + 5];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int c[n + 5];
  for (int i = 0; i < n; i++) {
    c[i] = 0;
  }
  int p = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i - 1]) {
      c[p]++;
      p++;
    } else
      c[p]++;
  }
  c[p]++;
  p++;
  int ans = 0;
  while (count(c, c + p, 0) < p - 1) {
    ans += p - count(c, c + p, 0) - 1;
    for (int i = 0; i < p; i++) {
      if (c[i] > 0) c[i]--;
    }
  }
  cout << ans;
  return 0;
}
