#include <bits/stdc++.h>
using namespace std;
int n, a[666666];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  sort(a + 1, a + 1 + n);
  multiset<int> sb;
  for (int i = 1; i <= n; ++i) sb.insert(a[i]);
  int aa = 0;
  for (int i = n; i >= 1; --i) {
    auto g = sb.upper_bound(a[i]);
    if (g != sb.end()) ++aa, sb.erase(g);
  }
  printf("%d\n", aa);
}
