#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int tmp = 0;
  int maxx = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i + 1]) {
      maxx = max(maxx, i - tmp);
      tmp = i;
    }
  }
  maxx = max(maxx, n - tmp);
  cout << n - maxx << endl;
  return 0;
}
