#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i = 0;
  int rem = 0, res = 0, past;
  map<int, int> m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    m[x] += 1;
    res = max(res, m[x]);
  }
  cout << n - res << endl;
  m.clear();
  return 0;
}
