#include <bits/stdc++.h>
using namespace std;
const long double pi = acosl(-1.0l);
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  int r = 0, i = 0;
  while (true) {
    int j = i + 1;
    while (j - i < n && ((a[j % n] == a[i % n]) || (a[j % n] == -1))) {
      ++j;
    }
    if (j - i >= n)
      break;
    else if (a[j % n] > a[i % n])
      ++r;
    a[i % n] = -1;
    i = j;
  }
  cout << r << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cerr.precision(15);
  cerr << fixed;
  cout.precision(15);
  cout << fixed;
  solve();
  return 0;
}
