#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, cnt = 0;
  cin >> n;
  long long int ary[n];
  for (long long int i = 0; i < n; ++i) cin >> ary[i];
  sort(ary, ary + n);
  long long int j = n - 1;
  for (long long int i = n - 2; i >= 0; i--) {
    if (ary[j] > ary[i]) {
      cnt++;
      j--;
    }
  }
  cout << cnt << endl;
  return 0;
}
