#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<long long int, long long int> mp;
  long long int ar[n + 5];
  long long int br[n + 5];
  long long int maxm = 0;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
    maxm = max(maxm, mp[ar[i]]);
  }
  cout << n - maxm << endl;
  return 0;
}
