#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int inf = 1e8;
struct table {
  int l, d;
};
table t[maxn];
int cnt[maxn];
int sum[maxn];
int num[maxn];
int ss[maxn];
bool cmp(table a, table b) {
  if (a.l == b.l) return a.d < b.d;
  return a.l < b.l;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    memset(cnt, 0, sizeof(cnt));
    memset(sum, 0, sizeof(sum));
    memset(ss, 0, sizeof(ss));
    memset(num, 0, sizeof(num));
    int low = inf, up = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &t[i].l);
      cnt[t[i].l]++;
      low = min(t[i].l, low);
      up = max(t[i].l, up);
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &t[i].d);
    }
    sort(t, t + n, cmp);
    for (int i = 0; i < n; i++) {
      sum[t[i].l] += t[i].d;
    }
    for (int i = up; i >= low; i--) {
      ss[i] = ss[i + 1] + cnt[i];
      sum[i] += sum[i + 1];
    }
    int tt = 0;
    int ans = inf;
    int temp;
    for (int i = low; i <= up; i++) {
      if (!cnt[i]) continue;
      while (tt < n && t[tt].l < i) {
        num[t[tt++].d]++;
      }
      temp = sum[i + 1];
      int p = n - ss[i];
      for (int j = 1; j <= 200; j++) {
        if (p < cnt[i]) break;
        if (p - cnt[i] + 1 < num[j]) {
          temp += (p - cnt[i] + 1) * j;
          p -= cnt[i] - 1;
          break;
        }
        temp += num[j] * j;
        p -= num[j];
      }
      ans = min(ans, temp);
    }
    printf("%d\n", ans);
  }
  return 0;
}
