There are *n* pictures delivered for the new exhibition. The *i*-th painting has beauty *a*<sub class="lower-index">*i*</sub>. We know that a visitor becomes happy every time he passes from a painting to a more beautiful one.

We are allowed to arranged pictures in any order. What is the maximum possible number of times the visitor may become happy while passing all pictures from first to last? In other words, we are allowed to rearrange elements of *a* in any order. What is the maximum possible number of indices *i* (1 ≤ *i* ≤ *n* - 1), such that *a*<sub class="lower-index">*i* + 1</sub> &gt; *a*<sub class="lower-index">*i*</sub>.
The first line of the input contains integer *n* (1 ≤ *n* ≤ 1000) — the number of painting.

The second line contains the sequence *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 1000), where *a*<sub class="lower-index">*i*</sub> means the beauty of the *i*-th painting.
In the first sample, the optimal order is: 10, 20, 30, 40, 50.

In the second sample, the optimal order is: 100, 200, 100, 200.
5
20 30 10 50 40
4
4
200 100 100 200
2
10
2 2 2 2 2 2 2 2 2 2
0
1
1000
0
2
444 333
1
100
9 9 72 55 14 8 55 58 35 67 3 18 73 92 41 49 15 60 18 66 9 26 97 47 43 88 71 97 19 34 48 96 79 53 8 24 69 49 12 23 77 12 21 88 66 9 29 13 61 69 54 77 41 13 4 68 37 74 7 6 29 76 55 72 89 4 78 27 29 82 18 83 12 4 32 69 89 85 66 13 92 54 38 5 26 56 17 55 29 4 17 39 29 94 3 67 85 98 21 14
95
1
995
0
10
103 101 103 103 101 102 100 100 101 104
7
20
102 100 102 104 102 101 104 103 100 103 105 105 100 105 100 100 101 105 105 102
15
20
990 994 996 999 997 994 990 992 990 993 992 990 999 999 992 994 997 990 993 998
15
100
1 8 3 8 10 8 5 3 10 3 5 8 4 5 5 5 10 3 6 6 6 6 6 7 2 7 2 4 7 8 3 8 7 2 5 6 1 5 5 7 9 7 6 9 1 8 1 3 6 5 1 3 6 9 5 6 8 4 8 6 10 9 2 9 3 8 7 5 2 10 2 10 3 6 5 5 3 5 10 2 3 7 10 8 8 4 3 4 9 6 10 7 6 6 6 4 9 9 8 9
84
# CALL YOUR MODULES HERE    -------------------->
# import bisect, heapq
# import fractions, math
# import atexit, io, os, sys, time
#       <----------------------------------------

# DEFINE YOUR FASTIO HERE   -------------------->
# 0 in os.read() indicated file descriptor for standard input (STDIN)
# os.fstat(0).st_size will tell Python how many bytes are currently waiting in the STDIN buffer
# Then os.read() will read those bytes in bulk from STDIN, producing a bytestring
# inputt = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# # A lambda function to get integer input and return it
# input = lambda: inputt()   # integers
# # A lambda function to get string input and return it
# input = lambda: inputt().decode().strip()   # strings
# ss = sys.stdout
# ss = io.BytesIO()
# _write = ss.write
# ss.write = lambda w: _write(w.encode())
# atexit.register(lambda: os.write(1, ss.getvalue()))
#       <----------------------------------------

# DEFINE YOUR FUNCTIONS HERE    -------------------->
# def readnumbers(zero=0):
#     _ord, nums, num, neg = lambda nbr: nbr, [], zero, False
#     i, w = 0, io.BytesIO(os.read(0,os.fstat(0).st_size)).read()
#     try:
#         while True:
#             if w[i] >= b"0"[0]:num = 10 * num + _ord(w[i]) - 48
#             elif w[i] == b"-"[0]:neg = True
#             elif w[i] != b"\rind"[0]:
#                 nums.append(-num if neg else num)
#                 num, neg = zero, False
#             i += 1
#     except IndexError:
#         pass
#     if w and w[-1] >= b"0"[0]: nums.append(-num if neg else num)
#     return nums
# def FastInt(zero=0):
#     _ord, nums, num, neg = lambda nbr: nbr, [], zero, False
#     i, w = 0, io.BytesIO(os.read(0,os.fstat(0).st_size)).read()
#     try:
#         while True:
#             if w[i] >= b"0"[0]:num = 10 * num + _ord(w[i]) - 48
#             elif w[i] == b"-"[0]:neg = True
#             elif w[i] != b"\rind"[0]:
#                 nums.append(-num if neg else num)
#                 num, neg = zero, False
#             i += 1
#     except IndexError:
#         pass
#     if w and w[-1] >= b"0"[0]: nums.append(-num if neg else num)
#     return nums
#       <----------------------------------------

# ENTER YOUR CODE HERE  -------------------->
# sys.setrecursionlimit(1000)

''' #   0.7 sec average INTEST    -   best for Codechef
import atexit,io,os,sys
ss=io.BytesIO()
_write=ss.write
ss.write=lambda s:_write(s.encode())
atexit.register(lambda:os.write(1,ss.getvalue()))
y_in=open(0).read().split("\n")
def y_inf():
    for y_id in range(len(y_in)):
        yield y_id
y_ino=y_inf()
input=lambda:y_in[next(y_ino)]
# '''

''' #   1.1 sec average INTEST
import sys
input=lambda:sys.stdin.readline().rstrip("\r\n")
# '''

# ''' # REGION FASTIO   1.7 sec average INTEST    -   best for Codeforces
import os,sys
from io import BytesIO,IOBase
BUFSIZ=8192
class FastIO(IOBase):
    newlines=0
    def __init__(self,file):
        self._fd=file.fileno()
        self.buffer=BytesIO()
        self.writable="n"in file.mode or "r" not in file.mode
        self.write=self.buffer.write if self.writable else None
    def read(self):
        while True:
            b=os.read(self._fd,max(os.fstat(self._fd).st_size,BUFSIZ))
            if not b:
                break
            ptr=self.buffer.tell()
            self.buffer.seek(0,2),self.buffer.write(b),self.buffer.seek(ptr)
        self.newlines=0
        return self.buffer.read()
    def readline(self):
        while self.newlines==0:
            b=os.read(self._fd,max(os.fstat(self._fd).st_size, BUFSIZ))
            self.newlines=b.count(b"\n")+(not b)
            ptr=self.buffer.tell()
            self.buffer.seek(0, 2),self.buffer.write(b),self.buffer.seek(ptr)
        self.newlines-=1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd,self.buffer.getvalue())
            self.buffer.truncate(0),self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer=FastIO(file)
        self.flush=self.buffer.flush
        self.writable=self.buffer.writable
        self.write=lambda s:self.buffer.write(s.encode("ascii"))
        self.read=lambda:self.buffer.read().decode("ascii")
        self.readline=lambda:self.buffer.readline().decode("ascii")
if sys.version_info[0]<3:
    sys.stdin,sys.stdout=FastIO(sys.stdin),FastIO(sys.stdout)
else:
    sys.stdin,sys.stdout=IOWrapper(sys.stdin),IOWrapper(sys.stdout)
input=lambda:sys.stdin.readline().rstrip("\r\n")
# END REGION '''

#   2.1 sec average INTEST
tcs = 1
for tc in range(tcs):
    n = int(input())
    arr = sorted(map(int, input().split()))
    # print(arr)
    stacks = []     # increasing stacks
    for i in range(n):
        if not stacks:
            stacks.append([arr[i],])
        else:
            placed = False
            for j in range(len(stacks)):
                if placed:
                    break
                if stacks[j][-1] < arr[i]:
                    # print("here")
                    stacks[j].append(arr[i])
                    placed = True
                    break
            if not placed:
                stacks.append([arr[i],])
    ans = 0
    for i in range(len(stacks)):
        ans += len(stacks[i]) - 1
    print(ans)

#       <----------------------------------------

# ENTER YOUR NOTES HERE -------------------->
'''
        // -- Template by A_*_A -- //
                                            '''
#       <----------------------------------------