#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010], n, la, lb, ra, rb, ans1, ans2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) b[i] = a[i];
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  ans1 = ans2 = 0;
  la = lb = 1;
  ra = rb = n;
  for (int i = 1; i <= n; i++) {
    if (a[ra] > b[rb]) {
      ans1++;
      ra--;
      rb--;
    } else if (a[ra] < b[rb]) {
      ans2++;
      la++;
      rb--;
    } else if (a[la] > b[lb]) {
      ans1++;
      la++;
      lb++;
    } else {
      if (a[la] != b[rb]) ans2++;
      la++;
      rb--;
    }
  }
  cout << ans1 << endl;
  return 0;
}
