#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i = 0, j = -1, k = 0, ans = 0;
  cin >> n;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  while (k < n) {
    while (j + 1 < n && vec[i] == vec[j + 1]) {
      j++;
    }
    if (i == 0) {
      k = j + 1;
    } else {
      while (k < n && vec[i] == vec[k]) {
        k++;
      }
    }
    ans += min(j - i + 1, n - k);
    k += min(j - i + 1, n - k);
    i = j + 1;
    j = i - 1;
  }
  cout << ans << endl;
}
