#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   pair<int, int> p[N];   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     int i = 0, j = 0;     while (j < n) {       if (a[i] < a[j]) i++;       j++;     }     cout << i << endl;     return 0;   }   