#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[100010];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int ans = 0;
  int re = 0;
  for (int i = 0; i < n; i++) {
    int t = 1;
    while (a[i + 1] == a[i] && (i < n - 1)) {
      t += 1;
      i += 1;
    }
    if (i == n - 1) {
      cout << ans;
      return 0;
    } else if (i == n - 2) {
      cout << ans + 1;
      return 0;
    }
    re = max(re, i + 1);
    if (t < (n - re)) {
      re += t;
      ans += t;
    } else if (t == n - re) {
      ans += t;
      cout << ans;
      return 0;
    } else {
      ans += (n - re);
      cout << ans;
      return 0;
    }
  }
  return 0;
}
