#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  sort(vec.begin(), vec.end());
  int l = 0, count = 0, r = 1;
  while (r < n) {
    if (vec[l] < vec[r]) {
      l++;
      r++;
      count++;
      continue;
    }
    r++;
  }
  cout << count;
}
