#include <bits/stdc++.h>
using namespace std;
struct leg {
  int l;
  int cost;
};
bool myfunction1(leg a, leg b) { return a.l < b.l; }
bool myfunction2(leg a, leg b) { return a.cost > b.cost; }
leg a[100001];
int number[100001];
int c[201];
int main() {
  int n;
  cin >> n;
  int total_cost = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i].l;
    number[a[i].l]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].cost;
    total_cost += a[i].cost;
  }
  for (int i = 0; i < 100001; i++)
    if (number[i]) v.push_back(i);
  sort(a, a + n, myfunction1);
  if ((number[v.size() - 1] * 2) > n)
    cout << 0 << endl;
  else {
    int tmp = 0;
    int d = number[v[0]];
    for (int i = 0; i < d; i++) tmp += a[i].cost;
    int ans = tmp;
    for (int i = 0; i < d; i++) c[a[i].cost]++;
    for (int i = 1; i < (int)v.size(); i++) {
      tmp = 0;
      int q = number[v[i]];
      if (q == 1) {
        tmp = a[d].cost;
        c[tmp]++;
        d++;
      } else {
        int k = q - 1;
        std::vector<int> b(201, 0);
        for (int j = 0; j < k; j++) {
          for (int i = 200; i >= 0; i--) {
            if (c[i]) {
              tmp += i;
              --c[i];
              ++b[i];
              break;
            }
          }
        }
        for (int j = 0; j < q; j++) {
          tmp += a[d].cost;
          c[a[d].cost]++;
          d++;
        }
        for (int i = 0; i < 201; i++) {
          c[i] += b[i];
        }
      }
      ans = max(ans, tmp);
    }
    cout << total_cost - ans;
  }
}
