#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1000;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
struct Tree {
  long long l, r, sum, num;
} tree[210 * 4];
vector<long long> v[maxn];
long long sum[maxn], L[maxn], val[maxn], num[maxn];
void push_up(long long p) {
  tree[p].sum = tree[p * 2].sum + tree[p * 2 + 1].sum;
  tree[p].num = tree[p * 2].num + tree[p * 2 + 1].num;
}
void build(long long p, long long l, long long r) {
  tree[p].l = l;
  tree[p].r = r;
  tree[p].sum = tree[p].num = 0;
  if (l == r) {
    return;
  }
  long long mid = (l + r) >> 1;
  build(p * 2, l, mid);
  build(p * 2 + 1, mid + 1, r);
  push_up(p);
}
void modify(long long p, long long l, long long r, long long d) {
  if (tree[p].l == tree[p].r) {
    tree[p].sum += tree[p].l * d;
    tree[p].num += d;
    return;
  }
  long long mid = (tree[p].l + tree[p].r) >> 1;
  if (l <= mid) modify(p * 2, l, r, d);
  if (r > mid) modify(p * 2 + 1, l, r, d);
  push_up(p);
}
long long query(long long p, long long l, long long r, long long s) {
  if (tree[p].l == tree[p].r) {
    return tree[p].l * s;
  }
  long long mid = (tree[p].l + tree[p].r) >> 1;
  if (tree[p * 2].num >= s)
    return query(p * 2, l, mid, s);
  else
    return tree[p * 2].sum + query(p * 2 + 1, mid + 1, r, s - tree[p * 2].num);
}
int main(void) {
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  build(1, 1, 200);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> L[i];
  for (long long i = 1; i <= n; i++) {
    cin >> val[i];
    v[L[i]].push_back(val[i]);
    sum[L[i]] += val[i];
    modify(1, val[i], val[i], 1);
    num[L[i]]++;
  }
  long long tot = n;
  long long tmp = 0;
  long long ans = 0x3f3f3f3f;
  for (long long i = 100000; i >= 1; i--) {
    if (!num[i]) continue;
    for (auto j : v[i]) modify(1, j, j, -1);
    long long need = tot - num[i] - (num[i] - 1);
    if (need <= 0) {
      ans = min(ans, tmp);
      tot -= num[i];
      break;
    }
    ans = min(ans, tmp + query(1, 1, 200, need));
    tot -= num[i];
    tmp += sum[i];
  }
  cout << ans << "\n";
  return 0;
}
