#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int *a = new int[n];
  int *b = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  int val = 0;
  for (int i = 0; i < n - 1; i++) {
    int x = a[i];
    for (int j = i + 1; j < n; j++) {
      if (x < b[j]) {
        val++;
        b[j] = -1;
        j = n;
      }
    }
  }
  cout << val << endl;
  return 0;
}
