#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  map<long long int, long long int> m;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    m[x]++;
  }
  long long int maxi = -1;
  for (auto it : m) {
    if (maxi < it.second) maxi = it.second;
  }
  cout << n - maxi;
  return 0;
}
