#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> mV(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    mV[i] = x;
  }
  sort(mV.begin(), mV.end());
  int lI = 0;
  int swap = 0;
  for (int i = 1; i < n; i++) {
    if (mV[i] > mV[lI]) {
      lI++;
      swap++;
    }
  }
  cout << swap << endl;
}
