#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  int i = 0, j = 0;
  while (i < n and j < n) {
    if (a[i] == a[j]) {
      j++;
      continue;
    }
    if (j == n)
      break;
    else {
      ans++;
      i++;
      j++;
    }
  }
  cout << ans << '\n';
}
