#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  vector<int> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.push_back(a[i]);
  }
  int ans = 0;
  sort(s.begin(), s.end());
  vector<int>::iterator it;
  for (int i = 0; i < n; i++) {
    it = upper_bound(s.begin(), s.end(), a[i]);
    if (it != s.end()) {
      s.erase(it);
      ans++;
    }
  }
  cout << ans << endl;
}
