// package codeforces1;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.*;
import java.math.*;
import java.text.*;

public class A497D1 {

	static InputReader in = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = 1;
		PrintWriter out = new PrintWriter(System.out);
		while (t > 0) {
			int n = i();
			Integer arr[] = new Integer[n];
			for (int i = 0; i < n; i++) {
				arr[i] = i();
			}
			Arrays.sort(arr);
			int c=1;
			int ans=0;
			int l=0;
			int r=1;
			for(int i=0;i<n;i++) {
//				if(arr[l]
				if(arr[l]==arr[r]) {
					r++;
				}
				else {
					l++;
					r++;
					ans++;
				}
				if(r==n)
					break;
			}
			System.out.println(ans);

			out.println();

			t--;

		}
		out.close();

		//		long l=l();
		//		String s=s();     //	ONLY BEFORE SPACE IN STRING , ELSE USE BUFFER-READER

	}

	public static long pow(long a, long b) {
		long m = 1000000007;
		long result = 1;
		while (b > 0) {
			if (b % 2 != 0) {
				result = (result * a) % m;
				b--;
			}
			a = (a * a) % m;
			b /= 2;
		}
		return result % m;
	}

	public static long gcd(long a, long b) {
		if (a == 0) {
			return b;
		}
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return a * (b / gcd(a, b));
	}

	public static long l() {
		String s = in.String();
		return Long.parseLong(s);
	}

	public static void pln(String value) {
		System.out.println(value);
	}

	public static int i() {
		return in.Int();
	}

	public static String s() {
		return in.String();
	}

}

class pair {
	int x, y;

	pair(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

class CompareValue {

	static void compare(pair arr[], int n) {
		Arrays.sort(arr, new Comparator<pair>() {
			public int compare(pair p1, pair p2) {
				return p1.y - p2.y;
			}
		});
	}
}

class CompareKey {
	static void compare(pair arr[], int n) {
		Arrays.sort(arr, new Comparator<pair>() {
			public int compare(pair p1, pair p2) {
				return p2.x - p1.x;
			}
		});
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int Int() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String String() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return String();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}

	public double readDouble() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E') {
				return res * Math.pow(10, Int());
			}
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E') {
					return res * Math.pow(10, Int());
				}
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0) {
				writer.print(' ');
			}
			writer.print(objects[i]);
		}
		writer.flush();
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
		writer.flush();
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}

class IOUtils {
	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.Int();
		return array;
	}
}

/**
 * TO SORT VIA TWO KEYS , HERE IT IS ACCORDING TO ASCENDING ORDER OF FIRST AND
 * DESC ORDER OF SECOND
 * LIST name-list
 * ARRAYLIST
 * COPY PASTE
 *
 * Collections.sort(list, (first,second) ->{
		    	if(first.con >second.con)
		    		return -1;
		    	else if(first.con<second.con)
		    		return 1;
		    	else {
		    		if(first.index >second.index)
		    			return 1;
		    		else
		    			return -1;
		    	}

		    });
 *
 */

/**
 *

  DECIMAL FORMATTER
Double k = in.readDouble();

System.out.println(k);
DecimalFormat df = new DecimalFormat("#.##");
System.out.print(df.format(k));
out.printLine(k);
*
* */


// package codeforces1;

import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.io.*;
import java.math.*;
import java.text.*;

public class A497D1 {

	static InputReader in = new InputReader(System.in);
	static OutputWriter out = new OutputWriter(System.out);

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = 1;
		PrintWriter out = new PrintWriter(System.out);
		while (t > 0) {
			int n = i();
			Long arr[] = new Long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = l();
			}
			Arrays.sort(arr);
			int c=1;
			long ans=0L;
			int l=0;
			int r=1;
			for(int i=0;i<n;i++) {

				if((long)arr[l]==(long)arr[r]) {
					r++;
				}
				else {
//					System.out.println(l+" "+r);
					l++;
					r++;
					ans++;

				}

				if(r==n || l==n)
					break;
			}
			System.out.println(ans);

			out.println();

			t--;

		}
		out.close();

		//		long l=l();
		//		String s=s();     //	ONLY BEFORE SPACE IN STRING , ELSE USE BUFFER-READER

	}

	public static long pow(long a, long b) {
		long m = 1000000007;
		long result = 1;
		while (b > 0) {
			if (b % 2 != 0) {
				result = (result * a) % m;
				b--;
			}
			a = (a * a) % m;
			b /= 2;
		}
		return result % m;
	}

	public static long gcd(long a, long b) {
		if (a == 0) {
			return b;
		}
		return gcd(b % a, a);
	}

	public static long lcm(long a, long b) {
		return a * (b / gcd(a, b));
	}

	public static long l() {
		String s = in.String();
		return Long.parseLong(s);
	}

	public static void pln(String value) {
		System.out.println(value);
	}

	public static int i() {
		return in.Int();
	}

	public static String s() {
		return in.String();
	}

}

class pair {
	int x, y;

	pair(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

class CompareValue {

	static void compare(pair arr[], int n) {
		Arrays.sort(arr, new Comparator<pair>() {
			public int compare(pair p1, pair p2) {
				return p1.y - p2.y;
			}
		});
	}
}

class CompareKey {
	static void compare(pair arr[], int n) {
		Arrays.sort(arr, new Comparator<pair>() {
			public int compare(pair p1, pair p2) {
				return p2.x - p1.x;
			}
		});
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int Int() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String String() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return String();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}

	public double readDouble() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		double res = 0;
		while (!isSpaceChar(c) && c != '.') {
			if (c == 'e' || c == 'E') {
				return res * Math.pow(10, Int());
			}
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		}
		if (c == '.') {
			c = read();
			double m = 1;
			while (!isSpaceChar(c)) {
				if (c == 'e' || c == 'E') {
					return res * Math.pow(10, Int());
				}
				if (c < '0' || c > '9') {
					throw new InputMismatchException();
				}
				m /= 10;
				res += (c - '0') * m;
				c = read();
			}
		}
		return res * sgn;
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0) {
				writer.print(' ');
			}
			writer.print(objects[i]);
		}
		writer.flush();
	}

	public void printLine(Object... objects) {
		print(objects);
		writer.println();
		writer.flush();
	}

	public void close() {
		writer.close();
	}

	public void flush() {
		writer.flush();
	}
}

class IOUtils {
	public static int[] readIntArray(InputReader in, int size) {
		int[] array = new int[size];
		for (int i = 0; i < size; i++)
			array[i] = in.Int();
		return array;
	}
}

/**
 * TO SORT VIA TWO KEYS , HERE IT IS ACCORDING TO ASCENDING ORDER OF FIRST AND
 * DESC ORDER OF SECOND
 * LIST name-list
 * ARRAYLIST
 * COPY PASTE
 *
 * Collections.sort(list, (first,second) ->{
		    	if(first.con >second.con)
		    		return -1;
		    	else if(first.con<second.con)
		    		return 1;
		    	else {
		    		if(first.index >second.index)
		    			return 1;
		    		else
		    			return -1;
		    	}

		    });
 *
 */

/**
 *

  DECIMAL FORMATTER
Double k = in.readDouble();

System.out.println(k);
DecimalFormat df = new DecimalFormat("#.##");
System.out.print(df.format(k));
out.printLine(k);
*
* */


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class ReordertheArray {

     public static void main(String[] args)  {

        Scanner scanner = new Scanner(System.in);

        int n;
     n = scanner.nextInt();

     int [] f = new int [n];

     for (int i=0;i<n;i++){
         f[i]= Integer.parseInt(scanner.next());
     }

    HashMap<Integer, Integer> numberMap = new HashMap<>();

         int result = -1;
        int frequency = -1;
        int value;

        for (int i = 0; i < f.length; i++) {
            if (numberMap.containsKey(f[i])) {

                value =numberMap.get(f[i]);// It gets the second index of numberMap which is the freq of element

            if (value != -1)
                value += 1;
            if (value > frequency)
                 frequency = value;
                    result = f[i];
                    numberMap.put(f[i], value);// put the updated value in the map
                }

            else { //element is not in the map. put it with value or count as 1

                numberMap.put(f[i], 1);
            }
        }

        if (f.length != 0 && frequency == -1){
        System.out.print(n - (-frequency));}
        else
        System.out.print(n - frequency);
    }}


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class ReordertheArray {

     public static void main(String[] args)  {

        Scanner scanner = new Scanner(System.in);

        int n;
     n = scanner.nextInt();

     int [] f = new int [n];

     for (int i=0;i<n;i++){
         f[i]= Integer.parseInt(scanner.next());
     }

    HashMap<Integer, Integer> numberMap = new HashMap<>();

         int result = -1;
        int frequency = -1;
        int value;

        for (int i = 0; i < f.length; i++) {
            if (numberMap.containsKey(f[i])) {

                value =numberMap.get(f[i]);// It gets the second index of numberMap which is the freq of element

            if (value != -1)
                value += 1;
            if (value > frequency)
                 frequency = value;
                    result = f[i];
                    numberMap.put(f[i], value);// put the updated value in the map
                }

            else { //element is not in the map. put it with value or count as 1

                numberMap.put(f[i], 1);
            }
        }
        System.out.print(n-frequency);

    }

}


package test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {

	static Map<Integer, Integer> b = new TreeMap<Integer, Integer>();

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
		System.out.close();
	}
}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		int p = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[p]) {
				ans++;
				p++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


package test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


package test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Test {

	static Map<Integer, Integer> b = new TreeMap<Integer, Integer>();

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */

class TreeNode {
     int val;
     TreeNode left;
     TreeNode right;
     TreeNode(int x) { val = x; }
 }

class Solution {
    List<List<Integer>> ret;

    void dfs(TreeNode cur, int depth) {
        if (ret.size() <= depth) {
            List<Integer> list = new ArrayList<Integer>();
            list.add(cur.val);
            ret.add(list);
        }
        ret.get(depth).add(cur.val);
        dfs(cur.left, depth + 1);
        dfs(cur.right, depth + 1);
    }

    public List<List<Integer>> zigzagLevelOrder(TreeNode root) {
        ret = new ArrayList<List<Integer>>();
        dfs(root, 0);
        for (int i = 1; i < ret.size(); i+=2) {
        	int m = ret.get(i).size();
        	for (int j = 0; j < m / 2; j++) {
        		int t = ret.get(i).get(j);
        		int s = ret.get(i).get(m - j - 1);
        		ret.get(i).set(j, s);
        		ret.get(i).set(m - j - 1, t);
        	}
        }
        return ret;
    }
}


package test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


package test;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {

	static Map<Integer, Integer> b = new TreeMap<Integer, Integer>();

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		int p = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[p]) {
				ans++;
				p++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeMap;

public class Main  {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a= new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int start = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == a[0]) {
				start ++;
			}
		}

		int ans = 0;
		for (int i = start; i < n; i++) {
			if (a[i] > a[i - start]) {
				ans++;
			}
		}
		System.out.println(ans);
		System.out.flush();
	}
}


import java.util.*;
public class Main4 {

	static int permutation(ArrayList<Integer> arr){
		int i=0,count=0,j=0;
		while(i<arr.size()){
			//If the numer in J is bigger than i, it can be permuted. So, the count will be added 1.
			if(arr.get(j)<arr.get(i)){
				count++;
				j++;
			}
			i++;
		}
		i=j=0;
		return count;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> num = new ArrayList<Integer>();
		int count=0,tam = Integer.parseInt(sc.nextLine());
		String nums = sc.nextLine();
		String numArray[] = nums.split(" ");

		for(int i=0; i<numArray.length; i++)
			num.add(Integer.parseInt(numArray[i]));

		Collections.sort(num);
		System.out.println(permutation(num));
	}
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner entrada = new Scanner(System.in);
		int n = Integer.parseInt(entrada.nextLine());
		boolean valor = true;
		ArrayList<Integer> array = new ArrayList<Integer>(n);
		for (int x=0; x<n; x++) {
			array.add(new Integer(Integer.parseInt(entrada.next())));
			if (x!=0 && array.get(x) < array.get(x-1))
				valor = false;
		}

		if (!valor)
			array = merge(array);
		int contador = 0;
		int ls = 1;
		if (array.get(0).compareTo(array.get(n-1)) != 0) {
			for (int j=0; j<n-1; ++j)
			{
				for (int k=ls; j<n; ++j)
				{
					if (array.get(j).compareTo(array.get(k)) < 0) {
						ls = k;
						contador = contador + 1;
						break;
					}
				}
				ls = ls + 1;
			}
		}
		System.out.println(contador);
	}

		static <T extends Comparable<T>> ArrayList<T> merge(ArrayList<T> a) {
		if (a.size() == 1)
			return a;
		ArrayList<T> a1 = new ArrayList<T> (a.subList(0,a.size()/2));
		a1 = merge(a1);
		ArrayList<T> a2 = new ArrayList<T> (a.subList(a.size()/2,a.size()));
		a2 = merge(a2);
		ArrayList<T> af = new ArrayList<T>(a.size());
		for (int x=0; x<a.size(); x++) {
			if (a1.size() == 0) {
				af.add(a2.get(0));
				a2.remove(0);
			}
			else
				if (a2.size() == 0 || a1.get(0).compareTo(a2.get(0)) < 0) {
					af.add(a1.get(0));
					a1.remove(0);
				}
			 	else {
					af.add(a2.get(0));
					a2.remove(0);
				}
			}

		return af;
	}
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner entrada = new Scanner(System.in);
		int n = Integer.parseInt(entrada.nextLine());
		boolean valor = true;
		ArrayList<Integer> array = new ArrayList<Integer>(n);
		for (int x=0; x<n; x++) {
			array.add(new Integer(Integer.parseInt(entrada.next())));
			if (x!=0 && array.get(x) < array.get(x-1))
				valor = false;
		}

		if (!valor)
			array = merge(array);
		int contador = 0;
		int ls = 1;
		if (array.get(0).compareTo(array.get(n-1)) != 0) {
			for (int j=0; j<n-1; ++j)
			{
				for (int k=ls; j<n; ++j)
				{
					if (array.get(j).compareTo(array.get(k)) < 0) {
						ls = k;
						contador++;
						break;
					}
				}
				ls++;
			}
		}
		System.out.println(contador);
	}

		static <T extends Comparable<T>> ArrayList<T> merge(ArrayList<T> a) {
		if (a.size() == 1)
			return a;
		ArrayList<T> a1 = new ArrayList<T> (a.subList(0,a.size()/2));
		a1 = merge(a1);
		ArrayList<T> a2 = new ArrayList<T> (a.subList(a.size()/2,a.size()));
		a2 = merge(a2);
		ArrayList<T> af = new ArrayList<T>(a.size());
		for (int x=0; x<a.size(); x++) {
			if (a1.size() == 0) {
				af.add(a2.get(0));
				a2.remove(0);
			}
			else
				if (a2.size() == 0 || a1.get(0).compareTo(a2.get(0)) < 0) {
					af.add(a1.get(0));
					a1.remove(0);
				}
			 	else {
					af.add(a2.get(0));
					a2.remove(0);
				}
			}

		return af;
	}
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner entrada = new Scanner(System.in);
		int n = Integer.parseInt(entrada.nextLine());
		boolean valor = true;
		ArrayList<Integer> array = new ArrayList<Integer>(n);
		for (int x=0; x<n; x++) {
			array.add(new Integer(Integer.parseInt(entrada.next())));
			if (x!=0 && array.get(x) < array.get(x-1))
				valor = false;
		}

		if (!valor)
			array = merge(array);
		int contador = 0;
		int ls = 1;
		if (array.get(0).compareTo(array.get(n-1)) != 0) {
			for (int j=0; j<n-1; ++j)
			{
				for (int k=ls; j<n; ++j)
				{
					if (array.get(j).compareTo(array.get(k)) < 0) {
						ls = k;
						contador = contador + 1;
						break;
					}
				}
				ls = ls + 1;;
			}
		}
		System.out.println(contador);
	}

		static <T extends Comparable<T>> ArrayList<T> merge(ArrayList<T> a) {
		if (a.size() == 1)
			return a;
		ArrayList<T> a1 = new ArrayList<T> (a.subList(0,a.size()/2));
		a1 = merge(a1);
		ArrayList<T> a2 = new ArrayList<T> (a.subList(a.size()/2,a.size()));
		a2 = merge(a2);
		ArrayList<T> af = new ArrayList<T>(a.size());
		for (int x=0; x<a.size(); x++) {
			if (a1.size() == 0) {
				af.add(a2.get(0));
				a2.remove(0);
			}
			else
				if (a2.size() == 0 || a1.get(0).compareTo(a2.get(0)) < 0) {
					af.add(a1.get(0));
					a1.remove(0);
				}
			 	else {
					af.add(a2.get(0));
					a2.remove(0);
				}
			}

		return af;
	}
}


import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	static <T extends Comparable<T>> ArrayList<T> mergeSort(ArrayList<T> array) {
		if (array.size() == 1)
			return array;
		ArrayList<T> array1 = new ArrayList<T> (array.subList(0,array.size()/2));
		array1 = mergeSort(array1);
		ArrayList<T> array2 = new ArrayList<T> (array.subList(array.size()/2,array.size()));
		array2 = mergeSort(array2);
		ArrayList<T> arrayAns = new ArrayList<T>(array.size());
		for (int i = 0; i < array.size(); i++) {
			if (array1.size() == 0) {
				arrayAns.add(array2.get(0));
				array2.remove(0);
			}
			else if (array2.size() == 0 || array1.get(0).compareTo(array2.get(0)) < 0) {
				arrayAns.add(array1.get(0));
				array1.remove(0);
			} else {
				arrayAns.add(array2.get(0));
				array2.remove(0);
			}
		}

		return arrayAns;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = Integer.parseInt(s.nextLine());
		boolean ordenado = true;
		ArrayList<Integer> arr = new ArrayList<Integer>(n);
		for (int i = 0; i < n; i++) {
			arr.add(new Integer(Integer.parseInt(s.next())));
			if (i != 0 && arr.get(i) < arr.get(i-1))
				ordenado = false;
		}

		if (!ordenado)
			arr = mergeSort(arr);
		int count = 0;
		int limit = 1;
		if (arr.get(0).compareTo(arr.get(n-1)) != 0) {
			for (int i = 0; i < n - 1; ++i)
			{
				for (int j = limit; j < n; ++j)
				{
					if (arr.get(i).compareTo(arr.get(j)) < 0) {
						limit = j;
						count++;
						break;
					}
				}
				limit++;
			}
		}
		System.out.println(count);
	}
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        Integer arr[]=new Integer[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.ni();

        }
        Arrays.sort(arr);
        int i=n-1,j=n-2,ans=0;
        for(;i>=0&&j>=0;i--){
            while(j>=0&&arr[j]==arr[i])j--;
            if(j>=0)ans++;
            j--;
        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.ni();

        }
        Arrays.sort(arr);
        int i=n-1,j=n-2,ans=0;
        for(;i>=0&&j>=0;i--,j--){
            while(j>=0&&arr[j]==(arr[i])){
                j--;
            }
            if(j>=0){
                ans++;
            }

        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        TreeMap<Integer,Integer> map=new TreeMap<>();
        TreeMap<Integer,Integer> rem=new TreeMap<>();
        for(int i=0;i<n;i++){
            int a=sc.ni();
            if(map.containsKey(a)){
                map.replace(a,map.get(a)+1);
            }
            else map.put(a,1);
            if(rem.containsKey(a)){
                rem.replace(a,rem.get(a)+1);
            }
            else rem.put(a,1);
        }
        int ans=0;
        for(int i:map.descendingKeySet()){
            int s=map.get(i);
            while(s-->0){
                if(rem.lowerKey(i)!=null){
                    int x=rem.lowerKey(i);
                    rem.replace(x,rem.get(x)-1);
                    ans++;
                }
            }
        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        TreeMap<Integer,Integer> map=new TreeMap<>();
        TreeMap<Integer,Integer> rem=new TreeMap<>();
        for(int i=0;i<n;i++){
            int a=sc.ni();
            if(map.containsKey(a)){
                map.replace(a,map.get(a)+1);
            }
            else map.put(a,1);
            if(rem.containsKey(a)){
                rem.replace(a,rem.get(a)+1);
            }
            else rem.put(a,1);
        }
        int ans=0;
        for(int i:map.descendingKeySet()){
            int s=map.get(i);
            while(s-->0){
                if(rem.lowerKey(i)!=null){
                    int x=rem.lowerKey(i);
                    if(rem.get(x)==1)rem.remove(x);
                    else
                        rem.replace(x,rem.get(x)-1);
                    ans++;
                }
            }
        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        Integer arr[]=new Integer[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.ni();

        }
        Arrays.sort(arr);
        int i=n-1,j=n-2,ans=0;
        for(;i>=0;i--){
            while(j>=0&&arr[j]==arr[i])j--;
            if(j>=0)ans++;
        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        int arr[]=new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.ni();

        }
        Arrays.sort(arr);
        int ans=0;
        for(int i=0;i<n;i++){
            if(arr[i]>arr[ans])ans++;
        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        Integer arr[]=new Integer[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.ni();

        }
        Arrays.sort(arr);
        int i=n-1,j=n-2,ans=0;
        for(;i>=0&&j>=0;i--,j--){
            while(j>=0&&arr[j].equals(arr[i])){
                j--;
            }
            if(j>=0){
                ans++;
            }

        }
        w.println(ans);
        w.close();
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Prac{
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        }
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                }
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public String rs() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                    c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }
        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod=998244353L,mod1=1000000007;
    static int co[][];
    static void dsort(){
        Arrays.parallelSort(co,(o1,o2)->o1[0]!=o2[0]?o1[0]-o2[0]:o1[1]-o2[1]);
    }
    static long  power(long x, long y) {
        long temp=0;
        if( y == 0)
            return 1;
        temp = power(x, y/2);
        if (y%2 == 0)
            return (temp*temp);
        else
            return (((x*temp))*temp);
    }
    static long modInverse(long a, long m){
        long num=m;
        long x=1;
        long power=a;
        while(num>0){
              if(num%2==1){
                  x=(x*power);
            }
            num>>=1;
            power=(power*power);
        }
        return x;
    }
    static long ncr(int n,int r){
        if(n<r)return 0L;
        long ans=fact[n]/(fact[r]*fact[n-r]);
        return ans;
    }
    static long fact[]=new long[1000005];
    public static void findFact(){
        fact[0]=1;
        for(int i=1;i<=1000000;i++){
            fact[i]=(i*fact[i-1])%mod;
        }
    }
    static long nCr(int n,int r){
        if(n<r)return 0L;

        return (fact[n]*modInverse((fact[r]*fact[n-r])%mod,mod-2))%mod;
    }
    public static void main (String[] args)throws IOException{
        InputReader sc=new InputReader(System.in);
        int n=sc.ni(),c=0;
        Integer arr[]=new Integer[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.ni();

        }
        Arrays.sort(arr);
        int i=n-1,j=n-2,ans=0;
        for(;i>=0&&j>=0;i--,j--){
            while(j>=0&&arr[j]==arr[i])j--;
            if(j>=0)ans++;

        }
        w.println(ans);
        w.close();
    }
}


/* package codechef; // 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. */
public class Codechef
{
    static int mod=998244353;
	public static void main(String[] args) throws IOException {
		FastReader in =new FastReader(System.in);
		int n=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		arr[i]=in.nextInt();

	    Arrays.sort(arr);
	    int prev=arr[0];
	    int count=1;
	    int maxcount=0;
	    for(int i=1;i<arr.length;i++){
	        if(prev==arr[i]){
	        ++count;
	        maxcount=Math.max(count,maxcount);
	        }
	        else{
	            prev=arr[i];
	            count=1;
	            maxcount=Math.max(count,maxcount);
	        }
	    }
	    maxcount=Math.max(count,maxcount);
	   System.out.println(n-maxcount);

	}

}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


/* package codechef; // 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. */
public class Codechef
{
    static int mod=998244353;
	public static void main(String[] args) throws IOException {
		FastReader in =new FastReader(System.in);
		int n=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		arr[i]=in.nextInt();
		int i=0,j=n-1;
		int count=0;
		while(i<j){
		    if(arr[i]<arr[j]){
		       int temp=arr[i];
		       arr[i]=arr[j];
		       arr[j]=temp;
		       ++i;
		       ++count;
		    }
		    else if(arr[i]>arr[j]){
		        int temp=arr[i];
		        arr[i]=arr[j];
		        arr[j]=temp;
		        --j;
		        ++count;
		    }
		    else
		    ++i;
		}
		System.out.println(count);

	}

}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


/* package codechef; // 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. */
public class Codechef
{
    static int mod=998244353;
	public static void main(String[] args) throws IOException {
		FastReader in =new FastReader(System.in);
		int n=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		arr[i]=in.nextInt();
		Arrays.sort(arr);
		int i=0,j=n-1;
		int count=0;
		while(i<j){
		    if(arr[i]<arr[j]){
		       int temp=arr[i];
		       arr[i]=arr[j];
		       arr[j]=temp;
		       ++i;
		       ++count;
		    }
		    else if(arr[i]>arr[j]){
		        int temp=arr[i];
		        arr[i]=arr[j];
		        arr[j]=temp;
		        --j;
		        ++count;
		    }
		    else
		    ++i;
		}
		System.out.println(count);

	}

}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    String nextLine() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c != 10 && c != 13; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    char nextChar() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        return (char) c;
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), vis[] = new int[n], cnt = 0;
            Arrays.sort(a);
            for (int i = 0; i < n; ++i) {
                for (int j = i + 1; j < n; j++) {
                    if (a[j] > a[i] && vis[j] == 0) {
                        cnt++;
                        vis[j] = 1;
                        break;
                    }
                }
                vis[i] = 1;
            }
            out.println(cnt);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), min = func.min(a), cnt = 0;
            for (int i = 0; i < n; ++i) if (a[i] == min) cnt++;
            out.println(cnt == n ? 0 : cnt + 1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class func {
        public static int min(int... v) {
            int min = Integer.MAX_VALUE;
            for (int i : v) min = Math.min(min, i);
            return min;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), cnt = 0, max = 0;
            Arrays.sort(a);
            for (int i = 0; i < n - 1; ++i) {
                if (a[i] == a[i + 1]) {
                    cnt++;
                    max = Math.max(cnt, max);
                } else cnt = 0;
            }
            out.println(n - max - 1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), min = func.min(a), cnt = 0;
            for (int i = 0; i < n; ++i) if (a[i] > min) cnt++;
            out.println(cnt);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class func {
        public static int min(int... v) {
            int min = Integer.MAX_VALUE;
            for (int i : v) min = Math.min(min, i);
            return min;
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt(), a[] = in.readIntArray(n), cnt = 0, f = 0;
            Arrays.sort(a);
            for (int i = 0, j = 0; j < n; ) {
                while (j < n && a[j] <= a[i]) j++;
                while (j < n && a[j] > a[i]) {
                    j++;
                    i++;
                    cnt++;
                }
            }
            out.println(cnt);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int[] readIntArray(int size) {
            int[] array = new int[(int) size];
            for (int i = 0; i < size; i++) array[i] = nextInt();
            return array;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


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

public class cf {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        Integer[] arr = new Integer[n];
        for(int i=0;i<n;i++) arr[i] = sc.nextInt();
        Arrays.sort(arr);

        //pw.println(Arrays.toString(arr));

        int cnt = 0;
        int x = 0;
        for(int i=n-1;i>0;i--) {
            int j = i - 1;
            while(j > x && arr[j] >= arr[i]) {
                j--;
            }
            if(arr[i] > arr[j]) {
                x++;
                cnt++;
            }
        }

        pw.println(cnt);
        pw.close();
    }
}


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

public class cf {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt();
        Integer[] arr = new Integer[n];
        for(int i=0;i<n;i++) arr[i] = sc.nextInt();
        Arrays.sort(arr);

        //pw.println(Arrays.toString(arr));

        int cnt = 0;
        for(int i=n-1;i>0;i--) {
            int j = i - 1;
            while(j > 0 && arr[j] >= arr[i]) {
                j--;
            }
            if(arr[i] > arr[j]) {
                cnt++;
            }
        }

        pw.println(cnt);
        pw.close();
    }
}