#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> a;
  vector<bool> used;
  scanf("%d", &n);
  a.resize(n);
  used.resize(n);
  fill(used.begin(), used.end(), false);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int i = a.size() - 2;
  int j = i + 1;
  int answer = 0;
  while (i >= 0) {
    if (a[j] > a[i] && !used[i]) {
      answer++;
      used[i] = true;
      i--;
      j--;
    } else {
      i--;
    }
  }
  printf("%d\n", answer);
  return 0;
}
