#include <bits/stdc++.h>
using namespace std;
const int MAX = 1100;
int a[MAX];
int cnt[MAX];
void bubble_sort(int x) {
  float temp;
  int b, c;
  for (b = x; b > 1; b--)
    for (c = 1; c < b; c++)
      if (a[c + 1] < a[c]) {
        temp = a[c + 1];
        a[c + 1] = a[c];
        a[c] = temp;
      }
}
int main() {
  int n, k = 0, l = 1, shomar = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  bubble_sort(n);
  for (int i = 1; i <= n; i++) {
  }
  for (int i = 0; i < n; i++) cnt[i] = 1;
  while (l <= n) {
    if (a[l] == a[l + 1]) {
      cnt[k] += 1;
    } else {
      k++;
    }
    l++;
  }
  for (int i = 0; i < k; i++) {
  }
  int max1 = 0;
  for (int i = 0; i < k; i++) {
    if (cnt[i] >= max1) max1 = cnt[i];
  }
  for (int i = 0; i < max1; i++) {
    for (int j = 0; j < k; j++) {
      if (cnt[j] > 0) {
        shomar++;
        cnt[j] -= 1;
      }
    }
  }
  cout << shomar - max1;
  return 0;
}
