#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  vector<int> dp;
  for (int i = 0; i < n;) {
    int j = i;
    while (j < n && v[j] == v[i]) {
      j++;
    }
    dp.push_back(j - i);
    i = j;
  }
  int ans = 0;
  int s = dp.size();
  int l = (n - dp[s - 1]);
  int p = dp[s - 1];
  for (int i = 1; i < s; i++) {
    ans += min(dp[i - 1], dp[i]);
    dp[i] = max(dp[i - 1], dp[i]);
  }
  cout << ans << endl;
  return 0;
}
