#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
int n, ans;
int num[maxn];
map<int, int> mp;
map<int, int>::iterator it;
int main() {
  ios::sync_with_stdio(false);
  while (scanf("%d", &n) != EOF) {
    ans = 0;
    mp.clear();
    for (int i = 0; i < n; ++i) {
      scanf("%d", &num[i]);
      ++mp[num[i]];
    }
    sort(num, num + n);
    for (int i = 0; i < n; ++i) {
      it = mp.upper_bound(num[i]);
      if (it == mp.end()) {
        continue;
      }
      ++ans;
      --it->second;
      if (it->second == 0) {
        mp.erase(it);
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
