#include <bits/stdc++.h>
using namespace std;
long long n;
long long x;
unordered_map<long long, long long> used;
long long maxx = 0;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> x;
    used[x]++;
    maxx = max(maxx, used[x]);
  }
  cout << n - maxx << "\n";
  return 0;
}
