#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lli", &n);
  map<long long, long long> my;
  long long maxy = -1;
  for (int i = 0; i < n; i++) {
    long long x;
    scanf("%lli", &x);
    my[x]++;
    maxy = max(maxy, my[x]);
  }
  cout << (n - maxy) << endl;
}
