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