#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 6;
int a[maxn];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    priority_queue<int, vector<int>, greater<int> > q;
    while (q.size()) q.pop();
    q.push(a[0]);
    int sum = 0;
    for (int i = 1; i < n; i++) {
      q.push(a[i]);
      if (a[i] > q.top()) {
        sum++;
        q.pop();
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
