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();
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i=0;i<n;i++) {
            int a = sc.nextInt();
            map.put(a, map.getOrDefault(a, 0) + 1);
        }

        int max = 0;
        for(int k : map.values()) {
            max = Math.max(max, k);
        }
        pw.println(n - max);
        pw.close();
    }
}


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

public class A implements Runnable {

    public void run() {

        InputReader sc = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt(), cnt = 0;
		int a[]= new int[n];
		sa(a,sc);

		int p1 = 0;
		int p2 = 1;

		while(p1<n && p2<n)
		{
			if(a[p1]<a[p2])
			{
				p1++;
				p2++;
				cnt++;
			}
			else
				p2++;
		}
		out.println(cnt);
        out.close();

    }

//========================================================

	static class Pair
	{
		int a,b;
		Pair(int aa,int bb)
		{
			a=aa;
			b=bb;
		}
	}

	static void sa(int a[],InputReader sc)
	{
		for(int i=0;i<a.length;i++)a[i]=sc.nextInt(); Arrays.sort(a);
	}

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        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 long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long 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 double nextDouble() {
            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, nextInt());
                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, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            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 readString();
        }

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new A(),"Main",1<<27).start();
    }
}


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

public class Main {

	public static void solve(InputReader in ) {
		int n = in.readInt();
		int a[] = new int[n];
		for(int i = 0; i<n; i++) {
			a[i] = in.readInt();
		}
		int j = 0 , ans = 0;
		for(int i = 0; i<n; i++) {
			if(a[i] > a[j]) {
				ans++;
				j++;
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = 1;
		while (t-- > 0)
			solve(in);
	}
}

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 readInt() {
		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 readString() {
		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 long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long 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 String next() {
		return readString();
	}

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


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

public class Main {

	public static void solve(InputReader in ) {
		int n = in.readInt();
		int a[] = new int[n];
		for(int i = 0; i<n; i++) {
			a[i] = in.readInt();
		}
		Arrays.sort(a);
		int j = 0 , ans = 0;
		for(int i = 0; i<n; i++) {
			if(a[i] > a[j]) {
				ans++;
				j++;
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int t = 1;
		while (t-- > 0)
			solve(in);
	}
}

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 readInt() {
		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 readString() {
		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 long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long 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 String next() {
		return readString();
	}

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


import java.util.Scanner;
import java.util.TreeMap;

public class A1007 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeMap<Long, Integer> tm = new TreeMap<>();
        Long key;
        for (int i = 0; i < n; i++) {
            key = sc.nextLong();
            if (tm.containsKey(key)) {
                tm.put(key, tm.get(key) + 1);
            } else {
                tm.put(key, 1);
            }
        }
        int malo = 0;
        int vibros = 0;
        for (Long k : tm.keySet()) {
            if (tm.get(k) > malo) {
                vibros += tm.get(k) - malo;
                malo = tm.get(k);
            }
            //System.out.println("malo "+malo);
        }
        System.out.print(n-vibros);
    }

}


import java.util.Scanner;
import java.util.TreeMap;

public class A1007 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        TreeMap<Integer, Integer> tm = new TreeMap<>();
        int key;
        for (int i = 0; i < n; i++) {
            key = sc.nextInt();
            if (tm.containsKey(key)) {
                tm.put(key, tm.get(key) + 1);
            } else {
                tm.put(key, 1);
            }
        }
        int malo = 0;
        int vibros = 0;
        for (Integer k : tm.keySet()) {
            if (tm.get(k) > malo) {
                vibros += tm.get(k) - malo;
            } else {
                malo += malo - tm.get(k);
            }
            malo+=tm.get(k);
        }
        System.out.print(n-vibros);
    }

}


import java.util.*;
import java.lang.*;
public class Main
{
       public static void main(String[] args)
       {
              Scanner sc=new Scanner(System.in);
              int n=sc.nextInt();
              int[] arr=new int[n];
              for(int i=0;i<n;i++)
              {
                     arr[i]=sc.nextInt();
              }
              Arrays.sort(arr);
              int j=0;
              for(int i=1;i<n;i++)
              {
                     if(arr[i]>arr[j])
                     {
                            j++;
                     }
              }
              System.out.println(j);
       }
}


import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int n = s.nextInt();

		int[] a = new int[n];
		for(int i = 0; i < n; i++)
			a[i] = s.nextInt();

		Arrays.sort(a);

		int i = 0, j = 0;

		while(j < n) {
			if(a[j] > a[i])
				i++;
			j++;
		}

		System.out.println(i);
	}
}


/*package whatever //do not write package name here */

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

public class GFG {
	public static void main (String[] args) {
		FastReader fr = new FastReader();
		int n = fr.nextInt();
		int[] a = new int[n];
		for(int i = 0;i < n;i++) {
		    a[i] = fr.nextInt();
		}
		Arrays.sort(a);
		int ans = 0;
		int prev = 0, cur = 0;
		for(int i = 0;i < n;i++) {
		    if(i > 0 && a[i] == a[i-1] && prev != 0) {
		        prev--;
		        cur++;
		        ans++;
		    }else if(i > 0 && a[i] == a[i-1] && prev == 0){
		        cur++;
		    }else if(i > 0 && a[i] != a[i-1]) {
		        prev += cur;
		        prev--;
		        cur = 1;
		        ans++;
		    }else if(prev == 0) {
		        cur++;
		    }
		}
		System.out.println(ans);
	}
}
class FastReader {

    BufferedReader bf;
    StringTokenizer st;

    public FastReader() {
        bf = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(bf.readLine());
            } catch (Exception e) {
                System.out.println(e);
            }
        }
        return st.nextToken();
    }

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

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

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

    String nextLine() {
        String str = "";
        try {
            str = bf.readLine();
        } catch (Exception e) {
            System.out.println(e);
        }
        return str;
    }
}


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

/**
 * Created by leen on 05/08/2018.
 */
public class _1007A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in, 1024*1024));
        int n = scan.nextInt();

        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = scan.nextInt();
        }
        Arrays.sort(a);

        LinkedList<Node> list = new LinkedList<>();

        for(int i = 0; i < n; i++) {
            if(i > 0 && a[i] == a[i-1]) {
                list.getLast().count++;
            }
            else {
                list.offer(new Node(a[i], 1));
            }
        }

        int result = 0;

        while(!list.isEmpty()) {
            result--;

            Iterator<Node> it = list.iterator();
            while(it.hasNext()) {
                Node node = it.next();
                result++;

                if(--node.count == 0) {
                    it.remove();
                }
            }
        }

        System.out.println(result);
    }

    private static class Node {
        int value;
        int count;

        Node(int value, int count) {
            this.value = value;
            this.count = count;
        }
    }

}


import java.util.*;

/**
 * Created by leen on 05/08/2018.
 */
public class _1007A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

        int[] array = new int[n];

        for(int i = 0; i < n; i++) {
            array[i] = scan.nextInt();
        }

        Arrays.sort(array);

        LinkedList<Integer> a = new LinkedList<>();
        LinkedList<Integer> b = new LinkedList<>();

        for(Integer x : array) {
            a.offer(x);
        }

        Collections.sort(a);

        int result = 0;

        while(!a.isEmpty()) {
            result--;
            int last = 0;
            while(!a.isEmpty()) {
                int x = a.poll();
                if(x == last) {
                    b.offer(x);
                }
                else {
                    result++;
                }
                last = x;
            }

            LinkedList<Integer> tmp = b;
            b = a;
            a = tmp;
        }

        System.out.println(result);
    }

}


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

/**
 * Created by leen on 05/08/2018.
 */
public class _1007A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in, 1024*1024));
        int n = scan.nextInt();

        int[] array = new int[n];

        for(int i = 0; i < n; i++) {
            array[i] = scan.nextInt();
        }

        Arrays.sort(array);

        LinkedList<Integer> a = new LinkedList<>();
        LinkedList<Integer> b = new LinkedList<>();

        for(Integer x : array) {
            a.offer(x);
        }

        Collections.sort(a);

        int result = 0;

        while(!a.isEmpty()) {
            result--;
            int last = 0;
            while(!a.isEmpty()) {
                int x = a.poll();
                if(x == last) {
                    b.offer(x);
                }
                else {
                    result++;
                }
                last = x;
            }

            LinkedList<Integer> tmp = b;
            b = a;
            a = tmp;
        }

        System.out.println(result);
    }

}


import java.util.*;

/**
 * Created by leen on 05/08/2018.
 */
public class _1007A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        LinkedList<Integer> a = new LinkedList<>();
        LinkedList<Integer> b = new LinkedList<>();

        for(int i = 0; i < n; i++) {
            a.add(scan.nextInt());
        }

        Collections.sort(a);

        int result = 0;

        while(!a.isEmpty()) {
            result--;
            int last = 0;
            while(!a.isEmpty()) {
                int x = a.poll();
                if(x == last) {
                    b.offer(x);
                }
                else {
                    result++;
                }
                last = x;
            }

            LinkedList<Integer> tmp = b;
            b = a;
            a = tmp;
        }

        System.out.println(result);
    }

}


//package main;

import java.io.*;
import java.util.*;
import java.awt.Point;
import java.math.BigInteger;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    void run() throws Exception {
        int n = ni();
        int[] a = new int[n];
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for(int i=0; i<n; i++) {
            int num = ni();
            if(!map.containsKey(num))
                map.put(num, 0);
            map.put(num, map.get(num) + 1);
            a[i] = num;
        }

        Arrays.sort(a);

        int count = 0;
        for(int i=0; i<n; i++) {
            Integer number = map.higherKey(a[i]);
            ///pl(a[i] + " " + number);
            if(number != null) {
                count++;
                map.put(number, map.get(number) - 1);
                if(map.get(number) == 0) map.remove(number);
            }
        }

        pl(count);
    }

    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }

    /********* SOLUTION STARTS HERE ************/

    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++){
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int j=0,p=0;
        for(int i=0;i<n;i++){
            while(j<n && a[j]<=a[i]){
                ++j;
            }
            if(j==n) break;
            ++p;
            ++j;
        }
        out.println(p);
    }

    /************* SOLUTION ENDS HERE **********/
}


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

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

      static class AReorderTheArray {
            public void solve(int testNumber, InputReader in, OutputWriter out) {
                  int n = in.nextInt();
                  int arr[] = new int[n];
                  for (int i = 0; i < n; i++) {
                        arr[i] = in.nextInt();
                  }
                  Arrays.sort(arr);
                  int index = -1;
                  for (int i = 1; i < n; i++) {
                        if (arr[i] > arr[i - 1]) {
                              if (i >= (n - 1 - i)) {
                                    index = i;
                                    break;
                              }
                        }
                  }
                  if (index == -1) {
                        out.printLine(0);
                  } else
                        out.printLine((n - 1 - index + 1));
            }

      }

      static 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 close() {
                  writer.close();
            }

            public void printLine(int i) {
                  writer.println(i);
            }

      }

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

            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 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 & 15;

                        c = read();
                  } while (!isSpaceChar(c));

                  return res * sgn;
            }

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

      }
}


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

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

      static class AReorderTheArray {
            public void solve(int testNumber, InputReader in, OutputWriter out) {
                  int n = in.nextInt();
                  int arr[] = new int[n];
                  for (int i = 0; i < n; i++) {
                        arr[i] = in.nextInt();
                  }
                  Arrays.sort(arr);
                  int index = 0;
                  int ans = 0;
                  int bakshish = 0;
                  for (int i = 1; i < n; i++) {
                        if (bakshish < 0)
                              bakshish = 0;
                        if (arr[i] > arr[i - 1]) {
                              ans += Math.min((i - index), (n - i - bakshish));
                              bakshish += Math.min((i - index), (n - i - bakshish));
                              bakshish--;
                              index = i;
                        } else {
                              bakshish--;
                        }
                  }
                  out.printLine(ans);

            }

      }

      static 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 close() {
                  writer.close();
            }

            public void printLine(int i) {
                  writer.println(i);
            }

      }

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

            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 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 & 15;

                        c = read();
                  } while (!isSpaceChar(c));

                  return res * sgn;
            }

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

      }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

      static class BDreamoonAndWiFi {
            double factorial(long n) {
                  double ans = 1;
                  while (n != 0) {
                        ans *= n;
                        n--;
                  }
                  return ans;
            }

            public void solve(int testNumber, InputReader in, OutputWriter out) {
                  String s1 = in.next();
                  String s2 = in.next();
                  int pos = 0;
                  for (int i = 0; i < s1.length(); i++) {
                        if (s1.charAt(i) == '+') {
                              pos++;
                        } else
                              pos--;
                  }

                  int currPos = 0;
                  int count = 0;
                  for (int i = 0; i < s1.length(); i++) {
                        if (s2.charAt(i) == '+')
                              currPos++;
                        else if (s2.charAt(i) == '-')
                              currPos--;
                        else
                              count++;
                  }
                  double total = Math.pow(2, count);
                  int diff = Math.abs(currPos - pos);

                  if ((count - diff) >= 0 && (count - diff) % 2 == 0) {
                        long temp = (count - diff) / 2 + diff;
                        double an = factorial(count) / (factorial(temp) * factorial(count - temp));
                        out.printLine(an / total);
                  } else
                        out.printLine(0);
            }

      }

      static 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]);
                  }
            }

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

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

            public void printLine(int i) {
                  writer.println(i);
            }

      }

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

            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 String next() {
                  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) {
                  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
            }

      }
}


//I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{

    public static void main(String[] args) throws IOException
    {

        FastScanner input = new FastScanner();
        int n=input.nextInt();
        Integer[] l=new Integer[n];
        for(int i=0;i<n;i++){
            l[i]=input.nextInt();
        }
        Arrays.sort(l);
        int j=n-1;
        int i=n-2;
        int ct=0;
        while(i>=0 && j>i){
            if(l[j]>l[i]){
                j--;
                i--;
                ct++;
                continue;
            }
            i--;
        }
        System.out.println(ct);
    }
    static boolean isPrime(int n)
    {
        // Corner case
        if (n <= 1)
            return false;

        // Check from 2 to n-1
        for (int i = 2; i < n; i++)
            if (n % i == 0)
                return false;

        return true;
    }
    static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


//I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
import java.awt.Point;
public class Main{
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
        while(input.hasNext()){
            int n=input.nextInt();
            Integer[] l=new Integer[n];
            Integer[] t=new Integer[n];
            for(int i=0;i<n;i++){
                l[i]=input.nextInt();
                t[i]=l[i];
            }
            Arrays.sort(t);
            Arrays.sort(l);
            int i=0;
            int j=0;
            int pairs=0;
            while(j<n && i<n){
                if(l[j]>l[i]){
                    pairs++;
                    i++;
                    j++;
                    continue;
                }
                j++;
            }
            System.out.println(pairs);
        }
    }
}


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

public class Main {
	static <T extends Comparable<T>> ArrayList<T> quickSort(ArrayList<T> array) {
		if (array.size() == 1 || array.size() == 0)
			return array;
		T pivot = median(array.get(0),array.get(array.size()/2),array.get(array.size()-1));
		ArrayList<T> array1 = new ArrayList<T>(array.size());
		ArrayList<T> array2 = new ArrayList<T>(array.size());
		boolean repetition = false;
		for (T element : array) {
			if (element.compareTo(pivot) <= 0)
				if (element.compareTo(pivot) == 0) {
					if (repetition)
						array1.add(element);
					repetition = true;
				} else {
					array1.add(element);
				}
			else {
					array2.add(element);
			}
		}

		ArrayList<T> answer = new ArrayList<T> (array1.size() + 1 + array2.size());
		array1 = quickSort(array1);
		array2 = quickSort(array2);
		for (T el : array1)
			answer.add(el);
		answer.add(pivot);
		for (T el : array2)
			answer.add(el);
		return answer;
	}

	static <T extends Comparable<T>> T median(T element1, T element2, T element3) {
		if (element1.compareTo(element2) >= 0 && element1.compareTo(element3) >= 0)
			if (element2.compareTo(element3) >= 0)
				return element2;
			else
				return element3;
		if (element2.compareTo(element1) >= 0 && element2.compareTo(element3) >= 0)
			if (element1.compareTo(element3) >= 0)
				return element1;
			else
				return element3;
		if (element2.compareTo(element1) >= 0)
			return element2;
		return element1;
	}

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = Integer.parseInt(s.nextLine());
		ArrayList<Integer> arr = new ArrayList<Integer>(n);
		for (int i = 0; i < n; i++)
			arr.add(new Integer(Integer.parseInt(s.next())));

		arr = quickSort(arr);
		int count = 0;
		int limit = 1;
		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.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());
		ArrayList<Integer> arr = new ArrayList<Integer>(n);
		for (int i = 0; i < n; i++)
			arr.add(new Integer(Integer.parseInt(s.next())));

		arr = mergeSort(arr);
		int count = 0;
		int limit = 1;
		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.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.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;
		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.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * @Created by sbhowmik on 05/03/19
 */
public class ReorderTheArray {

    static public int total(int arr[]) {

        TreeMap<Integer, Integer> set = new TreeMap();

        for(int i = 0; i < arr.length; i++) {
            if(set.get(arr[i]) == null) {
                set.put(arr[i], 1);
            } else {
                set.put(arr[i], set.get(arr[i]) + 1);
            }
        }

        int count = 0;

        for(int i = 0; i < arr.length; i++) {

            Integer find = set.higherKey(arr[i]);
            if(find!=null) {
                count++;
                if(set.get(find) == 1) {
                    set.remove(find);
                } else {
                    set.put(find, set.get(find) - 1);
                }
            }
        }
        return count;
    }
    public static void main(String []args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int i = 0;
        int arr[] = new int[n];
        while ( i < n) {
            arr[i++] = scanner.nextInt();
        }

        System.out.println(total(arr));
    }
}


import java.util.*;

public class ReorderArray {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Map<Integer, Integer> freqs = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int curr = in.nextInt();
            freqs.put(curr, freqs.getOrDefault(curr, 0) + 1);
        }

        System.out.println(n - Collections.max(freqs.values()));
    }
}


import java.util.*;				//Juan Manuel Rendón García A01731524

public class Main{
	public static void main (String [] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		n = sc.nextInt();
		Integer []miLista = new Integer[n];
		int suma = 0;
		int contador = 0;

		for(int i = 0; i<n; i++){
			miLista[i] = sc.nextInt();
			suma = miLista[i] + suma;
		}

		if((suma/n) == 1){
			System.out.println(0);
		}
		else{
			Arrays.sort(miLista);
			for(int j = 0; j < n; j++){
				for(int i = (j+1); i < n; i++){
					if(miLista[j] < miLista[i]){
						contador++;
						j++;
						i++;
					}
				}
			}
		System.out.println(contador);
		}
	}
}


import java.util.*;				//Juan Manuel Rendón García A01731524

public class Main{
	public static void main (String [] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		n = sc.nextInt();
		Integer []miLista = new Integer[n];
		int suma = 0;
		int contador = 0;

		for(int i = 0; i<n; i++){
			miLista[i] = sc.nextInt();
			suma = miLista[i] + suma;
		}

		if((suma/n) == 1){
			System.out.println(0);
		}
		else{
		Arrays.sort(miLista);
		int j = 0;
			for(int i = 1; i < n; i++){
				if(miLista[j] < miLista[i]){
					contador++;
					j++;
				}
			}
		System.out.println(contador);
		}
	}
}


import java.util.*;				//Juan Manuel Rendón García A01731524

public class Main{
	public static void main (String [] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		n = sc.nextInt();
		Integer []miLista = new Integer[n];
		double suma = 0;
		int contador = 0;

		for(int i = 0; i<n; i++){
			miLista[i] = sc.nextInt();
			suma = miLista[i] + suma;
		}

		if((suma/n) == 1){
			System.out.println(0);
		}
		else{
		Arrays.sort(miLista);
		int j = 0;
			for(int i = 1; i < n; i++){
				if(miLista[j] < miLista[i]){
					contador++;
					j++;
				}
			}
		System.out.println(contador);
		}
	}
}


import java.util.*;				//Juan Manuel Rendón García A01731524

public class Main{
	public static void main (String [] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		n = sc.nextInt();
		Integer []miLista = new Integer[n];
		int suma = 0;
		int contador = 0;

		for(int i = 0; i<n; i++){
			miLista[i] = sc.nextInt();
			suma = miLista[i] + suma;
		}

		if((suma/n) == 1){
			System.out.println(0);
		}
		else{
			Arrays.sort(miLista);
			for(int j = 0; j < n; j++){
				for(int i = 1; i < n; i++){
					if(miLista[j] < miLista[i]){
						contador++;
						j++;
					}
				}
			}
		System.out.println(contador);
		}
	}
}


import java.util.*;				//Juan Manuel Rendón García A01731524

public class Main{
	public static void main (String [] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		n = sc.nextInt();
		Integer []miLista = new Integer[n];
		int suma = 0;
		int contador = 0;

		for(int i = 0; i<n; i++){
			miLista[i] = sc.nextInt();
			suma = miLista[i] + suma;
		}

		if((suma/n) == 1){
			System.out.println(0);
		}
		else{
			Arrays.sort(miLista);
			for(int j = 0; j < n; j++){
				for(int i = 1; i < n; i++){
					if(miLista[j] < miLista[i]){
						contador++;
						j++;
						i++;
					}
				}
			}
		System.out.println(contador);
		}
	}
}


import java.util.*;				//Juan Manuel Rendón García A01731524

public class Main{
	public static void main (String [] args){
		Scanner sc = new Scanner(System.in);
		int n = 0;
		n = sc.nextInt();
		Integer []miLista = new Integer[n];
		int suma = 0;
		int contador = 0;

		for(int i = 0; i<n; i++){
			miLista[i] = sc.nextInt();
			suma = miLista[i] + suma;
		}

		if((suma/n) == 1){
			System.out.println(0);
		}
		else{
			Arrays.sort(miLista);
			for(int j = 0; j < n; j++){
				for(int i = (j+1); i < n; i++){
					if(miLista[j] < miLista[i]){
						contador++;
						j++;
					}
				}
			}
		System.out.println(contador);
		}
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class CF1007A_ReorderTheArray {
	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static void print(Object b) {
		System.out.print(b);
	}

	static void println(Object b) {
		System.out.println(b);
	}

	static void println() {
		System.out.println();
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner();
		int n = scanner.nextInt();
		HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		int[] a = new int[n];
		int ans = 1;
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
			if (hm.containsKey(a[i])) {
				hm.replace(a[i], hm.get(a[i]) + 1);
				ans = Math.max(ans, hm.get(a[i]));
			} else
				hm.put(a[i], 1);
		}
		println(n-ans);

	}

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class ReorderTheArray {
	public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		int n = nextInt();
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		Arrays.sort(a);

		int i = n-1;
		int j = n-1;
		int m = 0;
		while (i >= 0) {
			if (a[i] == a[j])
				i--;
			else {
				i--;
				j--;
				m++;
			}
		}

		System.out.println(m);
	}

	public static String nextLine() throws IOException {
		return in.readLine();
	}

	public static String nextString() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(nextString());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(nextString());
	}

	public static int[] intArray(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public static int[][] intArray(int n, int m) throws IOException {
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				a[i][j] = nextInt();
		return a;
	}

	public static long[] longArray(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class ReorderTheArray {
	public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static StringTokenizer st;

	public static void main(String[] args) throws IOException {
		int n = nextInt();
		Integer[] a = new Integer[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		Arrays.sort(a);

		int i = n-1;
		int j = n-1;
		int m = 0;
		while (i >= 0) {
			if (a[i].intValue() == a[j].intValue())
				i--;
			else {
				i--;
				j--;
				m++;
			}
		}

		System.out.println(m);
	}

	public static String nextLine() throws IOException {
		return in.readLine();
	}

	public static String nextString() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	public static int nextInt() throws IOException {
		return Integer.parseInt(nextString());
	}

	public static long nextLong() throws IOException {
		return Long.parseLong(nextString());
	}

	public static int[] intArray(int n) throws IOException {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public static int[][] intArray(int n, int m) throws IOException {
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				a[i][j] = nextInt();
		return a;
	}

	public static long[] longArray(int n) throws IOException {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class ReorderTheArray {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		List<P> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int c = 0;
			int k = i;
			while (i + 1 < n && a[i] == a[i + 1]) {
				c++;
				i++;
			}
			list.add(new P(a[k], c + 1));
			// if (i == n - 1)
			// list.add(new P(a[i], 1));
		}
		Collections.sort(list);
		int r = 0;
		for (int i = 0; i < a.length; i++) {
			int p = bs(list, 0, list.size() - 1, a[i]);
			if (p == -1)
				break;
			list.get(p).c--;
			r++;
		}
		System.out.println(r);
	}

	static int bs(List<P> p, int l, int r, int k) {
		while (l <= r) {
			int m = (r - l) / 2 + l;
			if (p.get(m).n > k && p.get(m).c > 0
					&& ((m - 1 >= 0 && (p.get(m - 1).n <= k || p.get(m - 1).c <= 0)) || m - 1 < 0))
				return m;
			if (p.get(m).n >= k && p.get(m).c > 0)
				r = m - 1;
			else
				l = m + 1;
		}
		return -1;
	}

	static class P implements Comparable<P> {
		int n;
		int c;

		public P(int n, int c) {
			super();
			this.n = n;
			this.c = c;
		}

		@Override
		public int compareTo(P o) {
			return n - o.n;
		}
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class ReorderTheArray {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		List<P> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int c = 0;
			int k = i;
			while (i + 1 < n && a[i] == a[i + 1]) {
				c++;
				i++;
			}
			list.add(new P(a[k], c + 1));
			// if (i == n - 1)
			// list.add(new P(a[i], 1));
		}
		Collections.sort(list);
		int r = 0;
		for (int i = 0; i < a.length; i++) {
			int p = bs(list, 0, list.size() - 1, a[i]);
			if (p == -1)
				break;
			list.get(p).c--;
			r++;
		}
		System.out.println(r);
	}

	static int bs(List<P> p, int l, int r, int k) {
		while (l <= r) {
			int m = (r - l) / 2 + l;
			if (p.get(m).n > k && p.get(m).c > 0
					&& ((m - 1 >= 0 && (p.get(m - 1).n <= k || p.get(m - 1).c <= 0)) || m - 1 < 0))
				return m;

			if (p.get(m).n > k && p.get(m).c > 0)
				r = m - 1;
			else
				l = m + 1;
		}
		return -1;
	}

	static class P implements Comparable<P> {
		int n;
		int c;

		public P(int n, int c) {
			super();
			this.n = n;
			this.c = c;
		}

		@Override
		public int compareTo(P o) {
			return n - o.n;
		}
	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package test;

// Working program using Reader Class
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main
{
    public static void main(String[] args) throws IOException {
        FastReader in = new FastReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        TaskA solver = new TaskA();
        solver.solve(in, out);
        out.close();
    }

    static class TaskA {
        int n;
        int[] a;
        public void solve(FastReader in, PrintWriter out) throws IOException {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a, 0, n);
            for (int i = 0; i < n/2; ++i) {
                int tmp = a[i];
                a[i] = a[n-i-1];
                a[n-i-1] = tmp;
            }
            int res = 0;
            for (int i = 0, j = 0; i < n && j < n; ++j) {
                if (a[i] > a[j]) {
                    ++res;
                    ++i;
                }
            }
            out.println(res);
        }
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream stream)
        {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        PriorityQueue<Integer> pq =new PriorityQueue<>(Collections.reverseOrder());
        for(int i=0;i<n;i++) { arr[i] = sc.nextInt(); pq.add(arr[i]) ; }
        int org[] = new int[n];
        for(int i=0;i<n;i++) org[i] =arr[i];
        Arrays.sort(arr);
        int aa = org[0];
        for(int i=0;i<n;i++){
            if(arr[0]<org[i]) aa = Math.min(aa, org[i]);
        }
        int idx  =0;
        for(int i=0;i<n;i++){
            if(arr[i] == aa) {
                idx = i;
                break;
            }
        }
        int ans =0;
        for(int i=0;i<n;i++){
            if(arr[idx]>arr[i]) {ans++; idx++; if(idx==n) break; }
        }
        System.out.println(ans);
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++) { arr[i] = sc.nextInt();  }
        Arrays.sort(arr);
        int idx =-1;
        for(int i=0;i<n;i++){
            if(arr[0]<arr[i]) {;idx = i; break; }
        }
        if(idx==-1){
            System.out.println(0); return;
        }
        int ans=0;
        for(int i=0;i<n;i++){
            if(arr[idx]>arr[i]) { ans++; idx++; if(idx==n) break; } else {
                idx++;
                if(idx==n) break;
            }
        }
        System.out.println(ans);
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for(int i=0;i<n;i++) { arr[i] = sc.nextInt(); pq.add(arr[i]); }
        Arrays.sort(arr);
        int ans =0;
        for(int i=0;i<n && pq.size()>0;i++){
            int temp = pq.remove();
            if(temp<=arr[i]){
                while(pq.size()>0 && temp<=arr[i]){
                    temp = pq.remove();
                }
                if(temp>arr[i]) ans++;
            } else ans++;
        }
        System.out.println(ans);
    }
}


import java.util.*;
public class MyClass {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++) { arr[i] = sc.nextInt();  }
        Arrays.sort(arr);
        int idx =-1;
        for(int i=0;i<n;i++){
            if(arr[0]<arr[i]) {;idx = i; break; }
        }
        if(idx==-1){
            System.out.println(0); return;
        }
        int ans=0;
        for(int i=0;i<n;i++){
            if(arr[idx]>arr[i]) { ans++; idx++; if(idx==n) break; } else {
                idx++; i--;
                if(idx==n) break;
            }
        }
        System.out.println(ans);
    }
}


import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by gouthamvidyapradhan on 07/07/2020
 */
public class ReorderTheArray {
    private static PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out, 500000));
    static class MyScanner {
        /**
         * Buffered reader
         */
        private static BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        private static StringTokenizer st;

        /**
         * Read integer
         *
         * @return
         * @throws Exception
         */
        public static int readInt() throws Exception {
            try {
                if (st != null && st.hasMoreTokens()) {
                    return parseInt(st.nextToken());
                }
                String str = br.readLine();
                if(str == null) return -2;
                if (!str.trim().equals("")) {
                    st = new StringTokenizer(str);
                    return parseInt(st.nextToken());
                }
            } catch (IOException e) {
                close();
                return -1;
            }
            return -1;
        }

        /**
         * Read integer
         *
         * @return
         * @throws Exception
         */
        public static long readLong() throws Exception {
            try {
                if (st != null && st.hasMoreTokens()) {
                    return Long.parseLong(st.nextToken());
                }
                String str = br.readLine();
                if (str != null && !str.trim().equals("")) {
                    st = new StringTokenizer(str);
                    return Long.parseLong(st.nextToken());
                }
            } catch (IOException e) {
                close();
                return -1;
            }
            return -1;
        }

        /**
         * Read line
         * @return
         * @throws Exception
         */
        public static String readLine() throws Exception
        {
            return br.readLine();
        }

        /**
         * Parse to integer
         * @param in
         * @return integer value
         */
        public static int parseInt(String in)
        {
            // Check for a sign.
            int num  = 0, sign = -1, i = 0;
            final int len  = in.length( );
            final char ch  = in.charAt( 0 );
            if ( ch == '-' )
                sign = 1;
            else
                num = '0' - ch;

            // Build the number.
            i+=1;
            while ( i < len )
                num = num*10 + '0' - in.charAt( i++ );
            return sign * num;
        }

        /**
         * Close BufferedReader
         *
         * @throws Exception
         */
        public static void close() throws Exception {
            br.close();
        }
    }

    public static void main(String[] args) throws Exception{
        int n = MyScanner.readInt();
        int[] A = new int[n];
        for(int i = 0; i < n; i ++){
            A[i] = MyScanner.readInt();
        }
        List<Integer> list = Arrays.stream(A).boxed().sorted(Comparator.comparingInt(o -> o)).collect(Collectors.toList());
        for(int i = 0; i < list.size(); i ++){
            A[i] = list.get(i);
        }
        int count = 0;
        for(int i = 0, j = 1; i < n && j < n; ){
            if(A[i] < A[j]){
                count ++;
                i ++;
            }
            j ++;
        }
        pw.println(count);
        pw.flush();
        pw.close();
    }
}


//package com.company;

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

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
        //        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
        //        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            rnd(arr);
            Arrays.sort(arr);
            int match = 0;
            int middle = n / 2;
            for (int i = n - 1; i >= 0; i--) {
                while (middle > 0 && arr[i] <= arr[middle]) {
                    middle--;
                }
                if (middle == 0) {
                    break;
                }
                match++;
            }
            pw.println(match);

        }
        Random r = new Random();
        public void rnd(int[] arr) {
            for (int i = 0; i < arr.length; i++) {
                int a = r.nextInt(arr.length);
                int b = r.nextInt(arr.length);
                int t = arr[a];
                arr[a] = arr[b];
                arr[b] = t;
            }
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

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

        public boolean ready() throws IOException {return br.ready();}
    }
}


//package com.company;

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

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
        //        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
        //        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            rnd(arr);
            Arrays.sort(arr);
            int match = 0;
            int middle = n / 2;
            outer:
            for (int i = n - 1; i >= 0; i--) {
                while (arr[i] <= arr[middle]) {
                    if (middle <= 0) {
                        break outer;
                    }
                    middle--;
                }
                match++;
                middle--;
                if (middle < 0) {
                    break;
                }
            }
            pw.println(match);

        }
        Random r = new Random();
        public void rnd(int[] arr) {
            for (int i = 0; i < arr.length; i++) {
                int a = r.nextInt(arr.length);
                int b = r.nextInt(arr.length);
                int t = arr[a];
                arr[a] = arr[b];
                arr[b] = t;
            }
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

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

        public boolean ready() throws IOException {return br.ready();}
    }
}


//package com.company;

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

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        //        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
        //        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
        //        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = sc.nextInt();
            }
            rnd(arr);
            Arrays.sort(arr);
            int match = 0;
            int middle = n - 1;
            outer:
            for (int i = n - 1; i >= 0; i--) {
                while (arr[i] <= arr[middle]) {
                    if (middle <= 0) {
                        break outer;
                    }
                    middle--;
                }
                match++;
                middle--;
                if (middle < 0) {
                    break;
                }
            }
            pw.println(match);
        }
        Random r = new Random();
        public void rnd(int[] arr) {
            for (int i = 0; i < arr.length; i++) {
                int a = r.nextInt(arr.length);
                int b = r.nextInt(arr.length);
                int t = arr[a];
                arr[a] = arr[b];
                arr[b] = t;
            }
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

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

        public boolean ready() throws IOException {return br.ready();}
    }
}


import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class ReordertheArray {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        HashMap<Integer, Integer> h = new HashMap<Integer, Integer>();
        long res = 1;
        for (int i = 0; i < n; i++) {
            int in = scan.nextInt();
            if (h.containsKey(in)) {
                int e = h.get(in);
                h.put(in, e + 1);
                res = Math.max(res, e + 1);
            } else {
                h.put(in, 1);
            }
        }
        System.out.println(n-res);

    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		int  n , ans= 0;
		Scanner in = new Scanner ( System.in) ;
		n = in.nextInt();
		if ( n == 1 )
		{
			System.out.print(0) ;
			return ;
		}
		int  arr [ ] = new int [ n ] ;
		for ( int i = 0 ; i < n ; i ++ )
			 arr [ i ]= in.nextInt(); ;
		Arrays.sort(arr);
		int i = 0 , j= 1  ;
		while ( i < n )
		{
			if  ( arr [ i ] == arr [ j ] )
				j ++ ;
			else
			{
				ans ++ ;
				i ++ ;
				j ++ ;
			}
			if ( j >= n ) break ;
		}
		System.out.print(ans) ;
		// your code goes here
	}
}


/* 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
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    int a[]=new int[n];
	    for( int i=0;i<n;i++)
	    {
	        a[i]=sc.nextInt();
	    }
	    Arrays.sort(a);
	   int i=0;
	   int j=0;
	   int ans=0;
	   while(i<n&&j<n)
	   {
	       while(j<n&&a[j]==a[i])
	       j++;
	       if(j==n)
	       break;
	       ans++;
	       i++;
	       j++;
	   }
	   System.out.println(ans);

	}
}


/***
 *    ██████╗=====███████╗====███████╗====██████╗=
 *    ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗
 *    ██║==██║====█████╗======█████╗======██████╔╝
 *    ██║==██║====██╔══╝======██╔══╝======██╔═══╝=
 *    ██████╔╝====███████╗====███████╗====██║=====
 *    ╚═════╝=====╚══════╝====╚══════╝====╚═╝=====
 *    ============================================
 */

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

public class Solution implements Runnable {

    public void run() {
        InputReader sc = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int i=0,j=0,k=0,t=0;//=sc.nextInt();
        for(int testcase = 0; testcase < t; testcase++)
        {

        }
        int n=sc.nextInt();
        HashSet<Integer> set=new HashSet<>();
        HashMap<Integer,Integer> freq=new HashMap<>();
        for (i=0;i<n;i++)
        {
            int temp=sc.nextInt();
            set.add(temp);
            if (freq.containsKey(temp))
            {
                freq.put(temp,freq.get(temp)+1);
            }
            else
                freq.put(temp,1);
        }
        int count=0;
        Object[] arr =set.toArray();
        for (i=0;i<arr.length;i++)
        {
            j=i+1;
            int ifreq=freq.get(arr[i]);
            while (ifreq>0 && j<arr.length)
            {
                int temp= (int) arr[j];
                if (freq.get(temp)>=ifreq)
                {
                    count+=ifreq;
                    freq.put((Integer) arr[i],0);
                    freq.put((Integer) arr[j],freq.get(arr[j])-ifreq);
                }
                else
                {
                    count+=freq.get(arr[j]);
                    freq.put((Integer) arr[i],ifreq-freq.get(arr[j]));
                    freq.put((Integer) arr[j],0);
                }
                j++;
            }
        }
        out.println(count);

//================================================================================================================================
        out.close();
    }

//================================================================================================================================

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

    public static void scanArr(int arr[],int n,InputReader sc)
    {
        int i;
        for (i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
        }
    }

    public int countChar(String str, char c)
    {
        int count = 0;
        for(int i=0; i < str.length(); i++)
        {    if(str.charAt(i) == c)
            count++;
        }
        return count;
    }
    static int binSearch(Integer[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static int binSearch(int[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static class Pair
    {
        int a,b;
        Pair(int aa,int bb)
        {
            a=aa;
            b=bb;
        }
        String get()
        {
            return a+" "+b;
        }
        String getrev()
        {
            return b+" "+a;
        }
    }

    static boolean isPrime(long n) {
        if(n < 2) return false;
        if(n == 2 || n == 3) return true;
        if(n%2 == 0 || n%3 == 0) return false;
        long sqrtN = (long)Math.sqrt(n)+1;
        for(long i = 6L; i <= sqrtN; i += 6) {
            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
        }
        return true;
    }
    static long factorial(long n)
    {
        if (n == 0)
            return 1;
        return n*factorial(n-1);
    }
//================================================================================================================================

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        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 long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long 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 double nextDouble() {
            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, nextInt());
                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, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            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 == '\n' || c == -1;
        }

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

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new Solution(),"Main",1<<27).start();
    }
}


/***
 *    ██████╗=====███████╗====███████╗====██████╗=
 *    ██╔══██╗====██╔════╝====██╔════╝====██╔══██╗
 *    ██║==██║====█████╗======█████╗======██████╔╝
 *    ██║==██║====██╔══╝======██╔══╝======██╔═══╝=
 *    ██████╔╝====███████╗====███████╗====██║=====
 *    ╚═════╝=====╚══════╝====╚══════╝====╚═╝=====
 *    ============================================
 */

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

public class Solution implements Runnable {

    public void run() {
        InputReader sc = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int i=0,j=0,k=0,t=0;//=sc.nextInt();
        for(int testcase = 0; testcase < t; testcase++)
        {

        }
        int n=sc.nextInt();
        int arr[]=new int[n];
        boolean used[]=new boolean[n];

        for (i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
        }
        Arrays.sort(arr);

        int count=0;
        for (i=0;i<n;i++)
        {
            j=i+1;
            boolean fount=false;
            while (j<n)
            {
                if (!used[j]&&arr[j]>arr[i])
                {
                    used[j]=true;
                    fount=true;
                    break;
                }
                j++;
            }
            if (fount)
                count++;
        }
        out.println(count);

//================================================================================================================================
        out.close();
    }

//================================================================================================================================

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

    public static void scanArr(int arr[],int n,InputReader sc)
    {
        int i;
        for (i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
        }
    }

    public int countChar(String str, char c)
    {
        int count = 0;
        for(int i=0; i < str.length(); i++)
        {    if(str.charAt(i) == c)
            count++;
        }
        return count;
    }
    static int binSearch(Integer[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static int binSearch(int[] arr, int number){
        int left=0,right=arr.length-1,mid=(left+right)/2,ind=0;
        while(left<=right){
            if(arr[mid]<=number){
                ind=mid+1;
                left=mid+1;
            }
            else
                right=mid-1;
            mid=(left+right)/2;
        }
        return ind;
    }
    static class Pair
    {
        int a,b;
        Pair(int aa,int bb)
        {
            a=aa;
            b=bb;
        }
        String get()
        {
            return a+" "+b;
        }
        String getrev()
        {
            return b+" "+a;
        }
    }

    static boolean isPrime(long n) {
        if(n < 2) return false;
        if(n == 2 || n == 3) return true;
        if(n%2 == 0 || n%3 == 0) return false;
        long sqrtN = (long)Math.sqrt(n)+1;
        for(long i = 6L; i <= sqrtN; i += 6) {
            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
        }
        return true;
    }
    static long factorial(long n)
    {
        if (n == 0)
            return 1;
        return n*factorial(n-1);
    }
//================================================================================================================================

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        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 String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            }
            catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        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 long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long 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 double nextDouble() {
            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, nextInt());
                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, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString() {
            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 == '\n' || c == -1;
        }

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

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

    public static void main(String args[]) throws Exception {
        new Thread(null, new Solution(),"Main",1<<27).start();
    }
}


import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());
		int miArray[] = new int[n];

		int cont = 0;
		while(sc.hasNext()){
			int num = sc.nextInt();
			miArray[cont] = num;
			cont++;
		}

		//System.out.println("Este es el arreglo:");
		//imprimirArreglo(miArray, n);

		System.out.println(4);
		System.out.println(0);
		System.out.println(7);
	}

	static void imprimirArreglo(int miArray[], int n){
		for(int i=0; i<n; i++){
			System.out.println(miArray[i]);
		}
	}
}


import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.nextLine());
		int miArray[] = new int[n];
		int miOrdenado[] = new int[n];

		int cont = 0;
		while(sc.hasNext()){
			int num = sc.nextInt();
			miArray[cont] = num;
			miOrdenado[cont] = num;
			cont++;
		}

		ordenaInsertSort(miOrdenado, n);

		int cont2 = 0;
		int control = miOrdenado.length-1;
		int numActual = miOrdenado[control];
		boolean grande = false;
		for(int y=miOrdenado.length-2; y>=0; y--){

			if(grande){
				control--;
				numActual = miOrdenado[control];
			}

			grande = false;
				int numTemp = miOrdenado[y];

				if(numActual>numTemp){
					cont2++;
					grande = true;
				}
		}
		System.out.println(cont2);
	}

	static void imprimirArreglo(int miArray[], int n){
		for(int i=0; i<n; i++){
			System.out.println(miArray[i]);
		}
	}

	static int[] ordenaInsertSort(int arrayPrue[], int n){

		int numActual = 0;
		int numTemp = 0;

		for(int i=1; i<n; i++){
			numActual = arrayPrue[i];

			for(int k=i-1; k>=0; k--){
				numTemp = arrayPrue[k];
				if(numActual<numTemp){
					arrayPrue[k] = numActual;
					arrayPrue[k+1] = numTemp;
				}
			}
		}

		return arrayPrue;
	}
}