#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  int a[n + 1];
  for (int k = 1; k <= n; k++) cin >> a[k];
  sort(a + 1, a + 1 + n);
  int mx = 1;
  for (int k = n; k > 1; k--)
    if (a[k] == a[k - 1])
      mx++;
    else {
      ans = max(mx, ans);
      mx = 1;
    }
  ans = max(mx, ans);
  if (a[1] == a[n])
    cout << 0;
  else
    cout << n - ans;
  return 0;
}
