/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone{
	public static int sol(int arr[]){
		TreeMap<Integer,Integer> mp = new TreeMap<>(Collections.reverseOrder());
		for(int i=0;i<arr.length;i++){
			mp.put(arr[i],mp.getOrDefault(arr[i],0)+1);
		}
		int steps = 0;
		int next = 0;
		mp.pollLastEntry();
		for(int i:mp.keySet()){
			mp.put(i,mp.get(i)+next);
			steps=steps+mp.get(i);
			next=mp.get(i);
		}
		return steps;
	}
	public static void main (String[] args) throws java.lang.Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++){
			arr[i]=sc.nextInt();
		}
		System.out.println(sol(arr));
		
	}
}