#include <bits/stdc++.h>
using namespace std;
int n;
int a[101101];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int l = 0, r = n - 1, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[l] < a[i]) {
      ans++;
      l++;
    } else
      r--;
  }
  printf("%d\n", ans);
  return 0;
}
