#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxd = 205;
struct Node {
  int l, d;
} leg[maxn];
bool operator<(const Node &a, const Node &b) { return a.l > b.l; }
int n, tot[maxd], td = 0, md = 0;
int Solve(int st, int ed) {
  int cnt = ed - st;
  int res = td;
  for (int i = md; i >= 0 && cnt > 0; i--) {
    res -= min(cnt, tot[i]) * i;
    cnt -= min(cnt, tot[i]);
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> leg[i].l;
  for (int i = 0; i < n; i++) cin >> leg[i].d;
  for (int i = 0; i < n; i++) md = max(md, leg[i].d);
  sort(leg, leg + n);
  for (int i = 0; i < n; i++) {
    tot[leg[i].d]++;
    td += leg[i].d;
  }
  int p = 0;
  int res = INT_MAX, tot_d = 0;
  while (p < n) {
    int p1 = p + 1;
    while (p1 < n && leg[p1].l == leg[p].l) p1++;
    p1--;
    for (int i = p; i <= p1; i++) {
      tot[leg[i].d]--;
      td -= leg[i].d;
    }
    int tmp = tot_d + Solve(p, p1);
    res = min(tmp, res);
    for (int i = p; i <= p1; i++) tot_d += leg[i].d;
    p = p1 + 1;
  }
  cout << res << endl;
  return 0;
}
