#include <bits/stdc++.h>
using namespace std;
void fast_read() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
const int MaxSize = 100010;
int main() {
  fast_read();
  int n;
  int ans = 0;
  long long A[MaxSize];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  sort(A, A + n);
  int i = n - 1;
  int j = n - 2;
  while (j >= 0) {
    while (j >= 0 && A[j] >= A[i]) j--;
    if (j < 0) break;
    ans++;
    i--;
    j--;
  }
  cout << ans << endl;
  return 0;
}
