#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
int main() {
  int N, ele = -1;
  cin >> N;
  vector<int> A(N);
  int i;
  for (i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());
  int ans = 0, ctr = 0, x;
  for (i = 0; i < N; i += x) {
    x = upper_bound(A.begin(), A.end(), A[i]) -
        lower_bound(A.begin(), A.end(), A[i]);
    ans = ans + min(ctr, x);
    ctr = max(ctr, x);
  }
  cout << ans;
  return 0;
}
