#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
  } else {
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long p1 = 0, p2 = 1;
    while (p2 < n) {
      if (a[p1] < a[p2]) p1++;
      p2++;
    }
    cout << p1 << endl;
  }
}
