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