#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long arr[n];
  map<long long, int> s;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (s.find(arr[i]) == s.end())
      s.insert({arr[i], 1});
    else
      s[arr[i]]++;
  }
  int ans = 0;
  for (auto a : s) ans = max(ans, a.second);
  cout << (n - ans);
  return 0;
}
