#include <bits/stdc++.h>
using namespace std;
int tong[1010];
int main() {
  int n, sum = 0, ans = 0;
  for (int i = 0; i <= 1000; i++) tong[i] = 2000;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    if (tong[temp] == 2000) {
      tong[temp] = 0;
      sum++;
    }
    tong[temp]++;
  }
  sort(tong, tong + 1001);
  int s = 0;
  for (int i = 0; i < sum; i++)
    if (tong[i] > 0 && tong[i] - s > 0) {
      ans += (tong[i] - s) * (sum - i - 1);
      s = tong[i];
    }
  printf("%d\n", ans);
  return 0;
}
