#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
long long int exp(long long int a, long long int b) {
  long long int ans = 1;
  for (long long int i = 0; i < b; i++) ans *= a;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int tc = 1;
  while (tc--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (ll i = 0; i < n; i++) cin >> a[i];
    ;
    unordered_map<long long int, long long int> m;
    for (auto it : a) m[it]++;
    long long int m1 = 0;
    for (auto it : m) m1 = ((m1 > it.second) ? m1 : it.second);
    cout << n - m1;
  }
  return 0;
}
