#include <bits/stdc++.h>
using namespace std;
long long int n, l, r = 1, sol;
vector<int> all;
int main() {
  cin >> n;
  all.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> all[i];
  }
  sort(all.begin(), all.end());
  while (r < n) {
    if (all[l] < all[r]) {
      l++;
      r++;
      sol++;
    } else {
      r++;
    }
  }
  cout << sol << endl;
}
