#include <bits/stdc++.h>
using namespace std;
long long i, j, k, l, n, m, last, res;
long long a[100009];
queue<long long> q;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  q.push(1);
  for (i = 2; i <= n; i++) {
    if (!q.empty() && a[q.front()] < a[i]) {
      res++;
      q.pop();
    }
    q.push(i);
  }
  cout << res << endl;
  return 0;
}
