#include <bits/stdc++.h>
using namespace std;
long long M = 1000000007;
int main() {
  long long n, x, i, ans = 0;
  cin >> n;
  multiset<long long> a;
  vector<long long> v(n);
  for (auto &x : v) cin >> x;
  sort(v.begin(), v.end());
  for (i = 0; i < n; i++) {
    a.insert(v[i]);
    if (*a.begin() < v[i]) {
      ans++;
      a.erase(a.begin());
    }
  }
  cout << ans << endl;
}
