#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int a[MAXN], b[MAXN];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  int l1 = 1, l2 = 1, r1 = n, r2 = n, minn = 0, maxn = 0;
  for (int i = 1; i <= n; i++) {
    if (a[r1] > b[r2]) {
      minn++;
      r1--;
      r2--;
    } else if (a[r1] < b[r2]) {
      maxn++;
      l1++;
      r2--;
    } else if (a[l1] > b[l2]) {
      minn++;
      l1++;
      l2++;
    } else {
      if (a[l1] != b[r2]) maxn++;
      l1++;
      r2--;
    }
  }
  printf("%d\n", max(minn, maxn));
  return 0;
}
