#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
struct Node {
  int l, d;
  bool operator<(const Node &rhs) const {
    if (l != rhs.l) return l < rhs.l;
    return d < rhs.d;
  }
} a[maxn];
vector<int> has[222];
int pre[maxn];
int cnt[maxn];
void Debug() {
  for (int i = 1; i < 222; i++) {
    if (has[i].size() == 0) continue;
    printf("d=%d:", i);
    int n = has[i].size();
    for (int j = 0; j < n; j++) {
      printf(" %d", has[i][j]);
    }
    printf("\n");
  }
}
int main() {
  int n, ans;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].l);
    cnt[a[i].l]++;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].d);
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    has[a[i].d].push_back(a[i].l);
  }
  pre[0] = 0;
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + a[i].d;
  }
  ans = pre[n] - pre[1];
  int bef, aft, tot, l, pos;
  for (int i = n; i >= 1; i -= cnt[l]) {
    l = a[i].l;
    aft = pre[n] - pre[i];
    if (aft > ans) break;
    tot = max(i + 1 - 2 * cnt[l], 0);
    bef = 0;
    for (int j = 1; j < 222; j++) {
      pos = upper_bound(has[j].begin(), has[j].end(), l - 1) - has[j].begin();
      if (pos < tot) {
        bef += j * pos;
        tot -= pos;
      } else {
        bef += j * tot;
        break;
      }
    }
    ans = min(bef + aft, ans);
    if (ans == 130) {
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
