#include <bits/stdc++.h>
using namespace std;
int n;
const int MAX = 100010;
const int INF = 1000000 * 200;
typedef struct {
  int l;
  int d;
} Leg;
Leg leg[MAX];
int total;
int cnt[203];
bool cmp(Leg L1, Leg L2) { return L1.l < L2.l; }
void input() {
  total = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &leg[i].l);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &leg[i].d);
    total += leg[i].d;
  }
}
void solve() {
  memset(cnt, 0, sizeof(cnt));
  int i = 0, cost, num, temp, ans = INF;
  sort(leg, leg + n, cmp);
  while (i < n) {
    num = 0;
    cost = total;
    for (temp = i; leg[i].l == leg[temp].l; temp++) {
      num++;
      cost -= leg[temp].d;
    }
    num--;
    for (int j = 200; j >= 1 && num > 0; j--) {
      cost -= min(num, cnt[j]) * j;
      num -= cnt[j];
    }
    ans = min(ans, cost);
    for (temp = i; leg[i].l == leg[temp].l; temp++) {
      cnt[leg[temp].d]++;
    }
    i = temp;
  }
  printf("%d\n", ans);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    input();
    solve();
  }
}
