#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int a[maxn], t[maxn];
int n;
bool check(int mid) {
  int cnt = 0;
  for (int i = 0; i < mid; ++i) {
    if (a[n - mid + i] > a[i]) ++cnt;
  }
  return cnt >= mid;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  cout << l << endl;
  return 0;
}
