#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  map<int, int> freq;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    freq[arr[i]]++;
  }
  int answer = 0;
  map<int, int>::iterator itr = freq.begin();
  for (; itr != freq.end(); itr++) {
    answer = max(answer, itr->second);
  }
  answer = n - answer;
  cout << answer;
  return 0;
}
