#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double eps = (1e-12);
const int MOD = 1000000007;
int dcmp(double x, double y) { return fabs(x - y) <= eps ? 0 : x > y ? -1 : 1; }
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  multiset<int> s;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s.insert(a[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    auto it = s.upper_bound(a[i]);
    if (it != s.end()) {
      ans++;
      s.erase(it);
    }
  }
  cout << ans << endl;
  return 0;
}
