#include <bits/stdc++.h>
using namespace std;
const long long MOD = 2e9 + 1;
const double pi = acos(-1.0);
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    priority_queue<long long> q;
    vector<long long> v;
    for (long long i = 0; i < n; i++) {
      long long p;
      cin >> p;
      v.push_back(p);
    }
    sort(v.begin(), v.end());
    q.push(-v[0]);
    long long ans = 0;
    for (long long i = 1; i < n; i++) {
      if (v[i] > -1 * q.top()) {
        ans++;
        q.pop();
        q.push(-v[i]);
      } else {
        q.push(-v[i]);
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
