#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  long long a;
  while (cin >> n) {
    vector<long long> v;
    map<long long, int> mp;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      v.push_back(a);
      mp[a]++;
    }
    v.push_back(1000000000000000);
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++) {
      long long num = v[i], put;
      auto it = mp.upper_bound(num);
      if (it == mp.end()) {
        put = mp.begin()->first;
      } else {
        ans++;
        put = it->first;
      }
      mp[put]--;
      if (mp[put] == 0) mp.erase(put);
    }
    cout << ans << endl;
  }
}
