#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  map<int, int> c;
  map<int, int> temp;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (c.find(arr[i]) == c.end()) {
      c[arr[i]] = 1;
      temp[arr[i]] = 1;
    } else {
      c[arr[i]]++;
      temp[arr[i]]++;
    }
  }
  vector<int> set;
  map<int, int>::iterator it = c.begin();
  while (it != c.end()) {
    set.push_back(it->first);
    it++;
  }
  int l = 0, r = 1;
  if (set.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  vector<int> visited(set.size(), 0);
  while (r < set.size() && l < set.size()) {
    if (l >= r) {
      r++;
      continue;
    }
    int a;
    if (visited[l] && temp[set[l]] > 0)
      a = temp[set[l]];
    else
      a = c[set[l]];
    visited[l] = 1;
    int b = temp[set[r]];
    int p = min(a, b);
    a -= p;
    b -= p;
    ans += p;
    temp[set[l]] = a;
    temp[set[r]] = b;
    if (a == 0) l++;
    if (b == 0) r++;
  }
  cout << ans << endl;
  return 0;
}
