#include <bits/stdc++.h>
using namespace std;
int n, t, res;
map<int, int> mp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    mp[t]++;
    res = max(res, mp[t]);
  }
  printf("%d\n", n - res);
  return 0;
}
