#include <bits/stdc++.h>
using namespace std;
void sublime() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  sublime();
  int tc, i;
  int n;
  cin >> n;
  vector<int> v(n);
  for (i = 0; i < n; ++i) {
    cin >> v[i];
  }
  int windowsize = 1;
  sort(v.begin(), v.end());
  int ans = 0;
  for (i = 1; i < n; ++i) {
    if (v[i] > v[i - windowsize]) {
      ans++;
    } else
      windowsize++;
  }
  cout << ans << endl;
}
