#include <bits/stdc++.h>
using namespace std;
int main() {
  int num, arr[100005];
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + num);
  int cnt = 0;
  int j = num - 1, k = 0;
  for (int i = num - 2; i >= 0;) {
    if (arr[j] > arr[i]) {
      i--;
      j--;
      cnt++;
    } else {
      i--;
    }
  }
  cout << cnt << endl;
  return 0;
}
