#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, a[N], cnt = 0, pos = 0;
  vector<int> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(a, a + n, greater<int>());
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (v.back() > a[i]) {
      cnt++;
      v.pop_back();
    }
  }
  cout << cnt << '\n';
  return 0;
}
