#include <bits/stdc++.h>
using namespace std;
int n, i, flag;
int a[1005];
int main() {
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int ans = 0;
  flag = 1;
  while (flag) {
    sort(a + 1, a + n + 1);
    for (i = 2; i <= n; i++) {
      if (a[i] > a[i - 1] && a[i - 1] != 0) {
        a[i - 1] = 0;
        ans++;
      }
    }
    a[n] = 0;
    flag = 0;
    for (i = 1; i <= n; i++)
      if (a[i] != 0) {
        flag = 1;
        break;
      }
  }
  cout << ans << endl;
}
