#include <bits/stdc++.h>
using namespace std;
char a[200][200];
long long check(long long x, long long y, long long n) {
  if (x >= 0 and x < n and y >= 0 and y < n and a[x][y] == '.')
    return 1;
  else
    return 0;
}
void solve() {
  long long n;
  cin >> n;
  map<long long, long long> m;
  for (long long i = 0; i < n; i++) {
    long long t;
    cin >> t;
    m[t]++;
  }
  auto i = m.rbegin();
  long long ans = 0;
  long long hold = 0;
  for (; i != m.rend(); i++) {
    long long k = min(hold, i->second);
    ans += k;
    hold = hold - k + i->second;
  }
  cout << ans << endl;
  return;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
