#include <bits/stdc++.h>
using namespace std;
int n;
int s[100000];
namespace Solution1 {
int getMaxCount() {
  sort(s, s + n);
  int count = 0;
  int j = n - 1;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] < s[j]) {
      count++;
      --j;
    }
  }
  return count;
}
}  // namespace Solution1
using namespace Solution1;
int main() {
  while (scanf("%d", &n) == 1 && n > 0) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &s[i]);
    }
    int maxCount = getMaxCount();
    printf("%d\n", maxCount);
  }
}
