#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v, v2;
  int n, temp;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    v2.push_back(temp);
    v.push_back(temp);
  }
  int i = 0;
  int t = 0;
  sort(v.begin(), v.end());
  sort(v2.begin(), v2.end());
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    if (upper_bound(v2.begin(), v2.end(), v[i]) != v2.end()) {
      v2.erase(upper_bound(v2.begin(), v2.end(), v[i]));
      ans++;
    }
  }
  cout << ans;
}
