#include <bits/stdc++.h>
using namespace std;
long long poww(long long x, long long y) {
  long long res = 1;
  x %= 1000000007;
  for (; y; y >>= 1) {
    if (y & 1) res = res * x % 1000000007;
    x = x * x % 1000000007;
  }
  return res;
}
long long n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, i, a, temp, ans = 0;
  cin >> n;
  map<long long, long long, greater<long long> > m;
  for (i = 0; i < n; i++) {
    cin >> a;
    m[a]++;
  }
  for (auto it = m.begin(); it != m.end(); it++) {
    if (it != m.begin()) {
      if (it->second >= temp) {
        ans += temp;
        temp = it->second;
      } else {
        ans += it->second;
      }
    } else {
      temp = it->second;
    }
  }
  cout << ans << endl;
  return 0;
}
