#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> nums(n);
  int sol = 0;
  for (int i = 0; i < n; i++) cin >> nums[i];
  sort(nums.begin(), nums.end());
  int i = n - 1, j = n - 1;
  while (i >= 0 and j >= 0) {
    if (nums[j] > nums[i]) {
      i--;
      j--;
      sol++;
    } else {
      i--;
    }
  }
  cout << sol << endl;
}
