#include <bits/stdc++.h>
using namespace std;
long long int x[1000007], y[1000007], z[1000007];
int main() {
  {
    long long int a, b, c = 0, d, e, i, j, k, l, m, p, n, q, r, t, u, val, w,
                        tc, mn = 2134567891, mx = 0, sum = 0, ans = 0;
    cin >> n;
    for (i = 0; i < n; i++) cin >> x[i];
    sort(x, x + n);
    for (i = 0, j = 1; i < n, j < n; i++) {
      while (x[i] == x[j]) j++;
      if (x[i] < x[j]) c++, j++;
    }
    cout << c << endl;
  }
  return 0;
}
