#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++cnt[x];
  }
  int ans = 0;
  for (auto& [x, c] : cnt) {
    ans = max(ans, c);
  }
  cout << n - ans;
  return 0;
}
