#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; ++i) cin >> A.at(i);
  int ans = 0, j = 1;
  sort(A.begin(), A.end());
  for (int i = 0; i < n; ++i) {
    if (j >= n) break;
    while (true) {
      if (A.at(i) < A.at(j)) {
        ++j;
        ++ans;
        break;
      } else {
        ++j;
        if (j >= n) break;
      }
    }
  }
  cout << ans << endl;
}
