#include <bits/stdc++.h>
using namespace std;
int n, x, minn = 1001, res;
map<int, int> m;
vector<int> v;
int main() {
  scanf("%d", &n);
  for (int ttt = 1; ttt <= (n); ++ttt) {
    scanf("%d", &x);
    m[x]++;
    minn = ((minn) < (x) ? (minn) : (x));
  }
  m[minn]--;
  v.push_back(minn);
  for (int i = 2; i <= (n); ++i) {
    int ok = 0;
    for (__typeof((m).begin()) it = ((m).begin()); it != (m).end(); ++it) {
      if (it->second > 0 && it->first > v.back()) {
        ok = 1;
        m[it->first]--;
        v.push_back(it->first);
        break;
      }
    }
    if (ok)
      continue;
    else {
      minn = 1001;
      for (__typeof((m).begin()) it = ((m).begin()); it != (m).end(); ++it) {
        if (it->second > 0) {
          v.push_back(it->first);
          m[it->first]--;
          break;
        }
      }
    }
  }
  for (int i = 1; i <= (((int)(v).size()) - 1); ++i)
    if (v[i - 1] < v[i]) res++;
  printf("%d\n", res);
  return 0;
}
