#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const long long maxa = 32050;
const double x = (1.0 + sqrt(5.0)) / 2;
int main() {
  int n, ans = 0, sum = 0;
  int a[1100];
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i - 1]) {
      sum++;
    } else {
      int t = upper_bound(a + i, a + n, a[i - 1]) - a;
      if (t != n) {
        swap(a[i], a[t]);
        sum++;
      } else {
        ans += sum;
        sum = 0;
        sort(a + i, a + n);
      }
    }
  }
  ans += sum;
  cout << ans << endl;
  return 0;
}
