#include <bits/stdc++.h>
using namespace std;
const bool debug = false;
const long double PI = acos(-1);
const long long int MOD = 1000000007;
const long double EPS = 1e-9;
const long long int INF = 9e18;
inline long long int pow(int a, int b) {
  long long int ans = 1, base = a;
  while (b) {
    if (b & 1) {
      ans = (ans * base) % MOD;
    }
    base = (base * base) % MOD;
    b >>= 1;
  }
  return ans;
}
multiset<int> s1, s2;
int main() {
  int n, element, count = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> element;
    s1.insert(element);
    s2.insert(element);
  }
  for (auto it = s1.begin(); it != s1.end(); it++) {
    auto it_upper = s2.upper_bound(*it);
    if (it_upper != s2.end()) {
      if (*it_upper > *it) {
        count++;
      }
      s2.erase(it_upper);
    }
  }
  printf("%d\n", count);
  return 0;
}
