#include <bits/stdc++.h>
using namespace std;
int main() {
  priority_queue<int, vector<int>, greater<int> > pq;
  int n;
  scanf("%d", &n);
  int arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  sort(arr, arr + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (pq.empty()) {
      pq.push(arr[i]);
    } else {
      int x = pq.top();
      if (x < arr[i]) {
        pq.pop();
        cnt++;
      }
      pq.push(arr[i]);
    }
  }
  printf("%d\n", cnt);
  return 0;
}
