#include <bits/stdc++.h>
using namespace std;
void HIK_FILEOPEN(string fileTxt) {
  string inp = fileTxt + ".in", outp = fileTxt + ".out";
  freopen(inp.c_str(), "r", stdin);
  freopen(outp.c_str(), "w", stdout);
}
long long int MOD(long long int number, long long int module) {
  if (number < 0) return MOD(number + module, module);
  return number % module;
}
long long int POW(long long int x, long long int pow) {
  long long int res = 1;
  for (long long int i = 0; i < pow; i++) {
    res *= x;
  }
  return res;
}
long long int n;
vector<long long int> arr;
void fill_arr() {
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    arr.push_back(x);
  }
}
map<long long int, long long int> st;
int main() {
  cin >> n;
  fill_arr();
  sort(arr.rbegin(), arr.rend());
  for (long long int i = 0; i < n; i++) {
    st[arr[i]]++;
  }
  map<long long int, long long int>::iterator it = st.end();
  it--;
  long long int res = 0;
  bool ite = true;
  for (long long int i = 0; i < n; i++) {
    long long int number = arr[i];
    while ((number <= it->first || it->second <= 0) && ite) {
      if (it == st.begin()) {
        ite = false;
        break;
      }
      it--;
    }
    if (!ite && (number <= it->first || it->second <= 0)) {
      break;
    } else {
      res++;
      it->second--;
    }
  }
  cout << res;
  return 0;
}
