#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, pair<long long int, long long int> > > v;
  long long int a[n];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(make_pair(a[i], make_pair(i, 1)));
  }
  sort(v.begin(), v.end());
  long long int j = 0, ans = 0;
  for (long long int i = 0; i < n; i++) {
    long long int val = v[i].first;
    while (val == v[j].first && j < n) j++;
    while (j < n && v[j].second.second == 0) {
      j++;
    }
    if (j == n) {
      break;
    }
    v[j].second.second = 0;
    long long int used = v[j].second.second;
    if (v[j].first > val) ans++;
  }
  cout << ans;
  return 0;
}
