#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, k;
  vector<int> vec;
  vector<int>::iterator it;
  map<int, int> mp;
  map<int, int>::iterator it2;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &k);
    mp[k]++;
  }
  while (1) {
    bool chk = false;
    for (it2 = mp.begin(); it2 != mp.end(); it2++) {
      if (it2->second > 0) {
        chk = true;
        break;
      }
    }
    if (!chk) break;
    for (it2 = mp.begin(); it2 != mp.end(); it2++) {
      if (it2->second != 0) {
        k = it2->first;
        vec.push_back(k);
        mp[k]--;
      }
    }
  }
  int cnt = 0;
  for (i = 0; i < vec.size() - 1; i++) {
    if (vec[i] < vec[i + 1]) cnt++;
  }
  cout << cnt;
}
