#include <bits/stdc++.h>
using namespace std;
const int inf = 10000000;
int num[1010];
int n, ans, m;
int main() {
  int x, now;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    num[x]++;
  }
  for (int i = 1; i <= 1000; i++) {
    if (num[i]) num[++m] = num[i];
  }
  int rem = m;
  for (int i = 1; i <= m; i++) {
    int now = inf;
    for (int j = 1; j <= m; j++) now = min(now, num[j]);
    if (now == inf) break;
    ans += now * (rem - 1);
    for (int j = 1; j <= m; j++)
      if (num[j] < inf) {
        num[j] -= now;
        if (num[j] == 0) num[j] = inf, rem--;
      }
  }
  cout << ans << endl;
}
