#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int arr[maxn], n;
bool valid(int k) {
  int p = n - 1;
  for (int i = k - 1; i >= 0; i--, p--)
    if (arr[i] >= arr[p]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  int l = 0, r = n;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    if (valid(mid))
      l = mid;
    else
      r = mid;
  }
  if (valid(r))
    cout << r << endl;
  else
    cout << l << endl;
}
