#include <bits/stdc++.h>
using namespace std;
char _;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long fpow(long long b, long long exp, long long mod) {
  if (exp == 0) return 1;
  long long t = fpow(b, exp / 2, mod);
  if (exp & 1) return t * t % mod * b % mod;
  return t * t % mod;
}
int num_elements, arr[100005], cnt;
vector<int> nums;
int main() {
  scanf("%d", &num_elements);
  for (int i = 1; i <= num_elements; i++) {
    scanf(" %d", &arr[i]);
    nums.push_back(arr[i]);
  }
  sort(nums.begin(), nums.end());
  for (int i = 1; i <= num_elements; i++) {
    int current = arr[i];
    vector<int>::iterator check =
        upper_bound(nums.begin(), nums.end(), current);
    if (check != nums.end()) {
      nums.erase(check);
      cnt++;
    }
  }
  printf("%d\n", cnt);
}
