#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  vector<int> arr(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
  }
  sort(arr.begin(), arr.end());
  int maxL = 1, l = 1, prev = arr[0];
  for (int i = 1; i < N; i++) {
    if (arr[i] == prev) {
      l++;
      if (l > maxL) maxL = l;
    } else {
      l = 1;
    }
    prev = arr[i];
  }
  printf("%d", N - maxL);
}
