#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 21;
map<int, int> mp;
int niz[maxn];
int main() {
  int n, m = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> niz[i];
    mp[niz[i]]++;
    m = max(m, mp[niz[i]]);
  }
  cout << n - m << endl;
  return 0;
}
