#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
int num[10005 + 1], a[10005 + 1], cnt[10005 + 1];
int main() {
  int n, i, j;
  while (scanf("%d", &n) != EOF) {
    memset(num, 0, sizeof(num));
    memset(cnt, 0, sizeof(cnt));
    for (i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      num[x]++;
    }
    int all = 0, ans = 0, temp = 0;
    for (i = 1; i <= 10005; i++) {
      if (num[i] != 0) {
        all++;
        cnt[num[i]]++;
      }
    }
    for (i = 1; i <= 10005; i++) {
      if (cnt[i] != 0) {
        ans += (all - 1) * (i - temp);
        all -= cnt[i];
        temp += i - temp;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
