#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, k;
  cin >> n;
  map<long long, long long> mp;
  queue<long long> q;
  long long cnt = 0, x = 0, a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    cnt = max(cnt, mp[a[i]]);
  }
  cout << n - cnt << endl;
}
