human
Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable.

In total the table Arthur bought has n legs, the length of the i-th leg is li.

Arthur decided to make the table stable and remove some legs. For each of them Arthur determined number di — the amount of energy that he spends to remove the i-th leg.

A table with k legs is assumed to be stable if there are more than half legs of the maximum length. For example, to make a table with 5 legs stable, you need to make sure it has at least three (out of these five) legs of the maximum length. Also, a table with one leg is always stable and a table with two legs is stable if and only if they have the same lengths.

Your task is to help Arthur and count the minimum number of energy units Arthur should spend on making the table stable.

Input

The first line of the input contains integer n (1 ≤ n ≤ 105) — the initial number of legs in the table Arthur bought.

The second line of the input contains a sequence of n integers li (1 ≤ li ≤ 105), where li is equal to the length of the i-th leg of the table.

The third line of the input contains a sequence of n integers di (1 ≤ di ≤ 200), where di is the number of energy units that Arthur spends on removing the i-th leg off the table.

Output

Print a single integer — the minimum number of energy units that Arthur needs to spend in order to make the table stable.

Examples

Input

2
1 5
3 2

Output

2

Input

3
2 4 4
1 1 1

Output

0

Input

6
2 2 1 1 3 3
4 3 5 5 2 1

Output

8
Solve the task in PYTHON3.

What is a Python program to print a single integer — the minimum number of energy units that Arthur needs to spend in order to make the table stable?
assistant
#Here is Python program to print a single integer — the minimum number of energy units that Arthur needs to spend in order to make the table stable.

#!/usr/bin/env python
# 557C_table.py - Codeforces.com 557C Table quiz
#
# Copyright (C) 2015 Sergey
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#       http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Input

The first line of the input contains integer n  the initial number of legs
in the table Arthur bought.

The second line of the input contains a sequence of n integers li, where
li is equal to the length of the i-th leg of the table.

The third line of the input contains a sequence of n integers di, where di
is the number of energy units that Arthur spends on removing the i-th leg
off the table.
Output

Print a single integer the minimum number of energy units that Arthur
needs to spend in order to make the table stable.
"""

# Standard libraries
import unittest
import sys
import re
import random
import bisect

# Additional libraries

###############################################################################
# Table Class
###############################################################################

class Table:
    """ Table representation """

    LIM = 201

    def __init__(self, args):
        """ Default constructor """

        self.legs = args[0]
        self.energy = args[1]
        self.n = len(self.legs)

        # Sort lists
        self.srt = sorted((l, e) for l, e in zip(self.legs, self.energy))
        self.legs = []
        self.energy = []
        for n in self.srt:
            self.legs.append(n[0])
            self.energy.append(n[1])

        # Prepare accumulator variables

        self.itot = 0
        self.ieltot = [0 for i in...