#include <bits/stdc++.h>
using namespace std;
int a[1111], cnt[1111];
int main() {
  int n, raz = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
    if (cnt[a[i]] == 1) raz++;
  }
  int res = 0;
  while (raz > 1) {
    res += raz - 1;
    for (int i = 1; i <= 1000; i++) {
      cnt[i]--;
      if (cnt[i] == 0) raz--;
    }
  }
  cout << res;
}
