#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N];
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  if (a[0] == a[n - 1]) {
    cout << 0 << endl;
    return 0;
  }
  int cur = 1;
  for (int i = 0; i < n - 1; i++) {
    for (int j = cur; j < n; j++) {
      if (a[i] < a[j]) {
        ans++;
        cur = j + 1;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
