#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int i = 0, j = 0, c = 0;
  while (i < n && j < n) {
    if (a[i] > a[j]) {
      c++;
      i++;
      j++;
    } else
      i++;
  }
  cout << c;
}
