#include <bits/stdc++.h>
using namespace std;
long long a[100005];
int main() {
  int n, i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  sort(a + 1, a + 1 + n);
  int now = 1, nex = 1;
  int ans = 0;
  while (now < n) {
    if (a[nex] > a[now]) {
      ans++;
      now++;
    }
    nex++;
    if (nex > n) break;
  }
  cout << ans << endl;
  return 0;
}
