#include <bits/stdc++.h>
long long int arr[100000];
void merge(int l, int m, int r) {
  int i, j, k;
  int n1 = m - l + 1;
  int n2 = r - m;
  long long int L[n1];
  long long int R[n2];
  for (i = 0; i < n1; i++) L[i] = arr[l + i];
  for (j = 0; j < n2; j++) R[j] = arr[m + 1 + j];
  i = 0;
  j = 0;
  k = l;
  while (i < n1 && j < n2) {
    if (L[i] <= R[j]) {
      arr[k] = L[i];
      i++;
    } else {
      arr[k] = R[j];
      j++;
    }
    k++;
  }
  while (i < n1) {
    arr[k] = L[i];
    k++;
    i++;
  }
  while (j < n2) {
    arr[k] = R[j];
    k++;
    j++;
  }
}
void mergesort(int l, int r) {
  if (l < r) {
    int mid = (l + r) / 2;
    mergesort(l, mid);
    mergesort(mid + 1, r);
    merge(l, mid, r);
  }
}
int main(void) {
  int n, max = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &arr[i]);
  mergesort(0, n - 1);
  int sim = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1]) {
      sim++;
    } else {
      sim = 1;
    }
    if (sim > max) {
      max = sim;
    }
  }
  printf("%d\n", n - max);
  return 0;
}
