#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, q, l, r, k, t, x, y, bugi = 0, chigi = 0, hagu = 10000, moga = 0, i,
                                 j;
  cin >> n;
  int a[n], b[10000] = {0};
  for (i = 0; i < n; i++) {
    cin >> x;
    a[i] = x;
    b[x]++;
  }
  bugi = 0;
  sort(b, b + 10000, greater<int>());
  while (x) {
    chigi = 0;
    x = n;
    for (i = n - 1; i >= 0; i--) {
      if (b[i]) {
        if (chigi) bugi++;
        chigi++;
        b[i]--;
      } else
        x--;
    }
    if (chigi < 2) break;
  }
  cout << bugi << endl;
  return 0;
}
