#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
long long a[N], cc[26];
vector<long long> v;
map<string, long long> mp;
multiset<long long> mm;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k, m, x, ans = 0, cnt = 0, maxi = 0, pos = 0, neg = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long p1 = 0, p2 = 0;
  while (p1 < n && p2 < n) {
    if (a[p1] == a[p2]) {
      p2++;
      continue;
    }
    if (p2 == n)
      break;
    else {
      cnt++;
      p1++;
      p2++;
    }
  }
  cout << cnt;
  return 0;
}
