#include <bits/stdc++.h>
using namespace std;
int N, num[100005], num2[100005];
int p1, p2, cnt;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> num[i];
  sort(num, num + N);
  while (p1 <= N - 1 && p2 <= N - 1) {
    if (num[p1] >= num[p2]) {
      p2++;
      continue;
    } else {
      cnt++;
      p1++;
      p2++;
    }
  }
  cout << cnt;
  return 0;
}
