#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7, N = 1e6 + 1;
int main() {
  long long n;
  cin >> n;
  map<long long, long long> mp;
  set<long long> s;
  for (long long i = 0; i < n; i++) {
    long long b;
    cin >> b;
    s.insert(b);
    mp[b]++;
  }
  long long maxx = 0;
  for (auto x : s) {
    maxx = max(maxx, mp[x]);
  }
  cout << n - maxx;
  return 0;
}
