#include <bits/stdc++.h>
using namespace std;
const int N = (int)(1e5 + 5);
const int LOG = (int)(20);
int ans, n, ar[N];
multiset<int> s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
    s.insert(ar[i]);
  }
  sort(ar + 1, ar + n + 1);
  for (int i = 1; i <= n; i++) {
    auto it = s.upper_bound(ar[i]);
    if (it == s.end()) break;
    ans++;
    s.erase(it);
  }
  printf("%d", ans);
}
