#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long arr[N], inc = 0;
  map<long long, long long> mp;
  deque<long long> dq;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    mp[arr[i]]++;
    if (mp[arr[i]] == 1) {
      dq.push_back(arr[i]);
    }
  }
  sort(arr, arr + N);
  sort(dq.begin(), dq.end());
  dq.pop_front();
  for (int i = 0; i < N; i++) {
    if (dq.size() > 0 && mp[dq.front()] > 0 && dq.front() > arr[i]) {
      mp[dq.front()]--;
      inc++;
    } else if (dq.size() > 0 && (dq.front() <= arr[i] || mp[dq.front()] <= 0)) {
      while (dq.size() > 0 && (dq.front() <= arr[i] || mp[dq.front()] <= 0)) {
        dq.pop_front();
      }
      if (dq.size() > 0 && mp[dq.front()] > 0 && dq.front() > arr[i]) {
        mp[dq.front()]--;
        inc++;
      }
    }
  }
  cout << inc << endl;
  return 0;
}
