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