#include <bits/stdc++.h>
using namespace std;
int a, b, nr, n;
int t[1100], fr[1100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &t[i]), fr[t[i]]++;
  for (int i = 1; i <= n; i++) t[i] = -1;
  bool ok = false;
  while (!ok) {
    ok = true;
    int last = 0;
    for (int i = 1; i <= n; i++)
      if (t[i] == -1) {
        for (int j = last + 1; j <= 1000; j++)
          if (fr[j] > 0) {
            t[i] = j, fr[j]--, last = j;
            ok = false;
            break;
          }
      }
  }
  int sol = 0;
  for (int i = 1; i < n; i++)
    if (t[i + 1] > t[i]) sol++;
  printf("%d", sol);
  return 0;
}
