#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
int a[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int res = 0;
  for (int i = 1, j = 1; i <= n; ++i)
    if (a[i] > a[j]) {
      ++res;
      ++j;
    }
  printf("%d\n", res);
  return 0;
}
