#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  int s = 0, e = 0;
  map<int, int> vis;
  int ans = 0;
  while (s < n && e < n) {
    if (b[s] < b[e]) {
      vis[b[e]] = 1;
      s++;
      e++;
      ans++;
    } else {
      e++;
    }
  }
  cout << ans;
}
