#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << ", ";
  err(++it, args...);
}
long long int x[1000007], y[1000007], z[1000007], n;
string s, S;
vector<long long int> v;
bitset<1000007> B;
int main() {
  {
    long long int a = 0, b = 0, c = 0, d, e, f, g, i, j, k, l, m, p, q, r, u, w,
                  t, tc = 1, in, loc, val, sz, lo, hi, mid, mn = 2134567891,
                  mx = 0, sum = 0, ans = 0;
    for (t = 1; t <= tc; t++) {
      cin >> n;
      for (i = 0; i < n; i++) cin >> x[i];
      sort(x, x + n);
      for (i = 0; i < n - 1; i++) {
        if (x[i] == x[i + 1]) {
          k = 0, j = i + 1;
          while (j < n && x[i] == x[j]) j++, k++;
          mx = max(mx, k);
        }
      }
      cout << n - mx - 1 << endl;
    }
  }
  return 0;
}
