#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
struct no {
  int l, d;
  bool operator<(const no& A) const { return l < A.l; }
} a[maxn];
int num[maxn];
int cnt[maxn];
int rmb[maxn];
bool vist[maxn];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(num, 0, sizeof num);
    memset(cnt, 0, sizeof cnt);
    memset(rmb, 0, sizeof rmb);
    memset(vist, 0, sizeof vist);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i].l), num[a[i].l]++;
    for (int i = 1; i <= n; i++) scanf("%d", &a[i].d);
    sort(a + 1, a + n + 1);
    int sum = 0;
    for (int i = n; i > 1; i--) {
      if (a[i].l == a[1].l) break;
      sum += a[i].d;
      if (a[i].l != a[i - 1].l) {
        rmb[a[i - 1].l] = sum;
      }
    }
    rmb[a[1].l] = sum;
    int ans = sum;
    cnt[a[1].d]++;
    vist[a[1].l] = 1;
    for (int i = 2; i <= n; i++) {
      if (vist[a[i].l]) {
        cnt[a[i].d]++;
        continue;
      }
      int c = i - num[a[i].l];
      sum = rmb[a[i].l];
      if (c > 0) {
        for (int j = 1; j <= 200; j++) {
          if (cnt[j]) {
            if (cnt[j] >= c) {
              sum += c * j;
              c = 0;
              break;
            } else {
              sum += cnt[j] * j;
              c -= cnt[j];
            }
          }
        }
      }
      ans = min(ans, sum);
      vist[a[i].l] = 1;
      cnt[a[i].d]++;
    }
    printf("%d\n", ans);
  }
  return 0;
}
