#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    v.push_back(arr[i]);
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  vector<int>::iterator up;
  for (int i = 0; i < n; i++) {
    up = upper_bound(v.begin(), v.end(), arr[i]);
    if (up < v.end()) {
      cnt++;
      v.erase(up);
    }
  }
  cout << cnt;
}
