#include <bits/stdc++.h>
int n, ar[1010];
int main() {
  int i, j, k, l, x, counter;
  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) scanf("%d", &ar[i]);
    l = 1010, counter = 0;
    for (i = 0; i < n; i++) {
      x = 1010, k = -1;
      for (j = 0; j < n; j++) {
        if (ar[j] != -1 && ar[j] > l) {
          if (ar[j] < x) x = ar[j], k = j;
        }
      }
      if (x == 1010) {
        x = 1010, k = -1;
        for (j = 0; j < n; j++) {
          if (ar[j] != -1 && ar[j] < x) {
            x = ar[j], k = j;
          }
        }
      } else
        counter++;
      ar[k] = -1, l = x;
    }
    printf("%d\n", counter);
  }
  return 0;
}
