#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, count = 0;
  vector<long> a, b;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long t;
    cin >> t;
    a.push_back(t);
  }
  b = a;
  sort(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    vector<long>::iterator it = upper_bound(b.begin(), b.end(), a[i]);
    if (it == b.end())
      continue;
    else {
      b.erase(it);
      count++;
    }
  }
  cout << count;
  return 0;
}
