#include <bits/stdc++.h>
using namespace std;
int n, l, r, ans;
int a[100005], b[100005];
void rd() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a + 1, a + n + 1);
}
int main() {
  rd();
  l = 1;
  r = n;
  for (int i = n; i >= 1; i--) {
    if (a[r] > a[i]) {
      r--;
      ans++;
    } else
      l++;
  }
  cout << ans;
  return 0;
}
