#include <bits/stdc++.h>
using namespace std;
long long dx[4] = {1, 0, -1, 0};
long long dy[4] = {0, -1, 0, 1};
template <class T>
void inputVector(vector<T>& v, long long n) {
  v.resize(n);
  for (long long i = 0; i < v.size(); i++) cin >> v[i];
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> a;
  inputVector(a, n);
  sort((a).begin(), (a).end());
  reverse((a).begin(), (a).end());
  multiset<long long> st;
  for (long long num : a) st.insert(-num);
  long long ret = 0;
  for (long long num : a) {
    auto it = st.upper_bound(-num);
    if (it != st.end()) {
      ret++;
      st.erase(it);
    }
  }
  cout << ret << endl;
  return 0;
}
