#include <bits/stdc++.h>
using namespace std;
int b[1005];
int main() {
  int n;
  scanf("%d", &n);
  int a[n + 1], ans = 0;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) b[a[i]]++;
  vector<int> arr;
  for (int i = 0; i < 1005; i++) {
    if (b[i] != 0) arr.push_back(b[i]);
  }
  sort(arr.begin(), arr.end());
  for (int i = 0; i < arr.size(); i++) {
    if (arr[i] != 0) {
      ans += (arr[i] * (arr.size() - i - 1));
      for (int j = arr.size() - 1; j >= i; j--) arr[j] = arr[j] - arr[i];
    }
  }
  cout << ans;
}
