#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int a[maxn];
int b[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int cnt = 1;
  b[0] = 0;
  b[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1])
      b[cnt]++;
    else {
      cnt++;
      b[cnt] = 1;
    }
  }
  sort(b + 1, b + cnt + 1);
  int ans = 0;
  for (int i = 1; i <= cnt; i++) {
    ans += (cnt - i) * (b[i] - b[i - 1]);
  }
  printf("%d\n", ans);
  return 0;
}
