#include <bits/stdc++.h>
const int MAX = 100005;
const int INF = 100000 * 200;
struct Leg {
  int l;
  int d;
};
int n;
Leg leg[MAX];
int cnt[205];
int total;
bool cmp(Leg l1, Leg l2) { return l1.l < l2.l; }
inline int min(int x, int y) { return x > y ? y : x; }
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));
  std::sort(leg, leg + n, cmp);
  int i = 0, num, temp, cost, ans = INF;
  while (i < n) {
    num = 0;
    cost = total;
    for (temp = i; leg[temp].l == leg[i].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[temp].l == leg[i].l; temp++) cnt[leg[temp].d]++;
    i = temp;
  }
  printf("%d\n", ans);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    input();
    solve();
  }
  return 0;
}
