#include <bits/stdc++.h>
using namespace std;
int n, c[300], ans = 2000000000, add;
const int max_n = 100100;
pair<int, int> p[max_n];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &p[i].first);
  for (int i = 0; i < n; i++) scanf("%d", &p[i].second);
  sort(p, p + n);
  for (int i = 0; i < n; i++) c[p[i].second]++;
  for (int i = n - 1; i >= 0;) {
    int ct = 0, j = i;
    for (; j >= 0; j--) {
      if (p[i].first == p[j].first)
        ct++;
      else
        break;
    }
    int add_ = add;
    for (int k = i; k > j; k--) {
      add += p[k].second;
      c[p[k].second]--;
    }
    if (j + 1 < ct) {
      printf("%d", min(add_, ans));
      return 0;
    }
    int cut = i - 2 * ct + 2;
    int cost = 0, it = 1;
    while (cut) {
      int minus = min(c[it], cut);
      cut -= minus;
      cost += minus * it;
      it++;
    }
    ans = min(ans, add_ + cost);
    i = j;
  }
  return 0;
}
