#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  queue<int> current;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (current.size() != 0 and current.front() < a[i]) {
      ++res;
      current.pop();
    }
    current.push(a[i]);
  }
  cout << res << endl;
}
