#include <bits/stdc++.h>
using namespace std;
map<int, int> cnt;
int main()
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
{
int a_i;
cin >> a_i;
cnt[a_i]++;
}
int mx = 0;
for(pair<int, int> el : cnt)
mx = max(mx, el.second);
cout << n - mx << endl;
return 0;
}