#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int n, maxn, a;
void solve() {
  for (int i = 0; i < n; i++) {
    cin >> a;
    m[a]++;
  }
  maxn = -1;
  map<int, int>::iterator it;
  for (it = m.begin(); it != m.end(); it++) {
    if (it->second > maxn) maxn = it->second;
  }
  cout << n - maxn << '\n';
}
int main() {
  cin >> n;
  solve();
  return 0;
}
