#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0;
  scanf("%d", &n);
  int v[n], v2[n];
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    v[i] = v2[i] = a;
  }
  sort(v, v + n);
  for (int i = 0, j = 0; j < n && i < n; i++, j++) {
    while (j < n && v[j] <= v[i]) j++;
    if (j == n) break;
    cnt++;
  }
  printf("%d", cnt);
  return 0;
}
