#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	
	int n;
	cin>>n;
	vector<int>arr(n+1,0);
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	//  store freq of each pile in hashmap
	map<int, int> mp;
	for(int i=1;i<=n;i++){
		mp[arr[i]]++;
		
	}
	
	vector<pair<int, int>>p;
	for(auto u : mp){
	 p.push_back({u.first, u.second});
	}
	int step=0;
	int size= p.size();
	
	for(int i= size-1;i>=1;--i){
		p[i-1].second= p[i-1].second+p[i].second;
		step= step+p[i].second;
		p[i].second=0;
	}
	cout<<step<<endl;
	return 0;
}