#include <bits/stdc++.h>
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cout << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cout.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
using namespace std;
long long n, m, k, q;
vector<long long> ar;
map<long long, long long> mp;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  ar.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
    mp[ar[i]]++;
  }
  long long cur = (mp.begin())->first;
  long long smaller = mp[cur];
  long long ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it == mp.begin()) continue;
    long long c = it->second;
    if (c <= smaller) {
      ans += c;
    } else {
      ans += smaller;
      smaller = c;
    }
  }
  cout << ans << endl;
  return 0;
}
