#include <bits/stdc++.h>
using namespace std;
const int MAXA = 1e5 + 5;
int n, a[MAXA], ans;
vector<int> List;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    List.push_back(a[i]);
  }
  sort(List.begin(), List.end());
  for (int i = 1; i <= n; i++) {
    vector<int>::iterator up;
    up = upper_bound(List.begin(), List.end(), a[i]);
    if (up != List.end()) {
      ans++;
      List.erase(up);
    }
  }
  cout << ans;
  return 0;
}
