#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long llinf = 1e18;
const long long nax = 0;
map<long long, long long> cnt;
long long n, maks = 0;
vector<long long> arr(100005);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    cnt[arr[i]]++;
    maks = max(maks, cnt[arr[i]]);
  }
  cout << n - maks << '\n';
}
