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