#include <bits/stdc++.h>
using namespace std;
struct AA {
  int len;
  int cost;
};
bool cmp(struct AA a, struct AA b) { return a.len < b.len; }
int main() {
  int n;
  cin >> n;
  struct AA aa[100010];
  int sum = 0;
  int ans = 2147483647;
  for (int i = 0; i < n; i++) {
    scanf("%d", &aa[i].len);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &aa[i].cost);
    sum += aa[i].cost;
  }
  sort(aa, aa + n, cmp);
  int cc = 0;
  int DP[210];
  for (int i = 0; i < 210; i++) DP[i] = 0;
  while (cc < n) {
    int costt = sum;
    int count = 0;
    for (int i = cc; aa[i].len == aa[cc].len; i++) {
      costt -= aa[i].cost;
      count++;
    }
    count--;
    for (int i = 200; i > 0 && count > 0; i--) {
      if (count > DP[i])
        costt -= DP[i] * i;
      else
        costt -= count * i;
      count -= DP[i];
    }
    if (ans > costt) ans = costt;
    int tmp;
    for (tmp = cc; aa[tmp].len == aa[cc].len; tmp++) {
      DP[aa[tmp].cost]++;
    }
    cc = tmp;
  }
  printf("%d\n", ans);
  return 0;
}
