#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x;
  cin >> n;
  vector<long long int> v, v1;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  long long int idx = 0;
  sort(v.begin(), v.end());
  long long int l = 0, r = 0;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (l >= n or r >= n) {
      break;
    }
    if (v[r] <= v[l]) {
      r++;
    } else {
      ans++;
      l++;
      r++;
    }
  }
  cout << ans << endl;
}
