#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, x, m1;
  string s;
  long long m;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long j = 0;
  for (long long i = 1; i < n; i++) {
    if (a[i] != a[0]) {
      j = i;
      break;
    }
  }
  long long p = 0;
  if (j == 0) {
    cout << 0;
    return;
  }
  long long r = j;
  for (long long i = 0; i < n; i++) {
    for (long long j = r; j < n; j++) {
      if (a[i] < a[j]) {
        r = j + 1;
        p++;
        break;
      }
    }
  }
  cout << p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  return 0;
}
