#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> A(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  int i = 0;
  int curr = A[0];
  int count = 0;
  int ans = 0;
  int bruh = 0;
  while (i < n) {
    if (A[i] == curr) {
      count++;
    } else {
      ans += min(bruh, count);
      bruh = max(bruh, count);
      curr = A[i];
      count = 1;
    }
    i++;
  }
  ans += min(bruh, count);
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
