#include <bits/stdc++.h>
using namespace std;
int main() {
  map<int, int> a;
  int n, m, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> m;
    a[m]++;
    ans = max(ans, a[m]);
  }
  cout << (n - ans);
}
