#include <bits/stdc++.h>
using namespace std;
int n, a[100005], f[100005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  deque<int> res;
  res.push_front(a[0]);
  for (int i = 1; i < n; i++)
    if (a[i] > res.back()) {
      res.pop_back();
      res.push_front(a[i]);
    } else
      res.push_front(a[i]);
  cout << n - res.size();
}
