#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 0, j = 0;
  cin >> n;
  long long a[n], mas[120000];
  for (int i = 0; i < 120000; i++) mas[i] = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n - 1; i++) {
    if (a[i] < a[i + 1]) {
      ans++;
      continue;
    }
    while (a[i] == a[i + 1]) {
      if (mas[j] == -1) mas[j] = 0;
      mas[j]++;
      i++;
    }
    i--;
    j++;
  }
  j = 0;
  long long pl = mas[0];
  for (int i = 1; i < 120000; i++) {
    if (mas[i] == 0) break;
    if (pl >= mas[i]) {
      ans = ans + mas[i];
    } else {
      ans = ans + pl;
      pl = mas[i];
    }
  }
  cout << ans;
  return 0;
}
