#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N;
  cin >> N;
  vector<long long int> Numbers(N);
  map<long long int, long long int> Count;
  for (long long int i = 0; i < N; i++) {
    cin >> Numbers[i];
    Count[Numbers[i]]++;
  }
  long long int Max = 0;
  for (auto i : Numbers) Max = max(Max, Count[i]);
  cout << N - Max;
}
