#include <bits/stdc++.h>
using namespace std;
long long n, k = 0, a[1000009];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int g = n;
  a[0] = 0;
  for (int i = n; i >= 1; i--) {
    while (a[i] == a[g]) {
      g--;
    }
    if (g == 0) break;
    if (a[i] > a[g]) g--, k++;
  }
  cout << k;
}
