#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1001] = {0}, n, i, count, val, j, ans = 0;
  vector<int> v;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &val);
    a[val]++;
  }
  for (i = 1; i < 1001; i++) {
    count = a[i];
    for (j = 0; j < v.size() && count > 0; j++) {
      if (v[j] < i) {
        v[j] = i;
        count--;
        ans++;
      }
    }
    for (j = 0; j < count; j++) {
      v.push_back(i);
    }
  }
  printf("%d", ans);
  return 0;
}
