#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> sor;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  sor.resize(n);
  for (int i = 0; i < n; i++) cin >> sor[i];
  sort(sor.begin(), sor.end());
  int tart = 0;
  int valasz = 0;
  for (int i = 0; i < n; i++) {
    while (tart < sor.size() && sor[tart] <= sor[i]) tart++;
    if (tart < sor.size()) {
      valasz++;
      tart++;
    }
  }
  cout << valasz << endl;
}
