#include <bits/stdc++.h>
using namespace std;
int d[100010], l[100010], num[200], num_l[100010], sum[100010], total[100010];
struct Leg {
  int l;
  int d;
  bool operator<(const Leg &x) const { return l < x.l; }
} b[100010];
int main() {
  int i, j, n;
  scanf("%d", &n);
  memset(num, 0, sizeof(num));
  memset(sum, 0, sizeof(sum));
  memset(total, 0, sizeof(total));
  memset(num_l, 0, sizeof(num_l));
  int low = 100000, high = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    low = min(low, l[i]);
    high = max(high, l[i]);
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &d[i]);
  }
  for (i = 0; i < n; i++) {
    num_l[l[i]]++;
    total[l[i]] += d[i];
  }
  for (i = high; i >= low; i--) {
    sum[i] = sum[i + 1] + num_l[i];
    total[i] += total[i + 1];
  }
  for (int i = 0; i < n; i++) {
    b[i].d = d[i];
    b[i].l = l[i];
  }
  sort(b, b + n);
  int cnt = 0;
  int ans = 1e9;
  int tmp;
  for (i = low; i <= high; i++) {
    if (!num_l[i]) continue;
    while (cnt < n && b[cnt].l < i) {
      num[b[cnt++].d]++;
    }
    tmp = total[i + 1];
    int p = n - sum[i];
    for (j = 1; j <= 200; j++) {
      if (p < num_l[i]) break;
      if (p - num_l[i] + 1 < num[j]) {
        tmp += (p - num_l[i] + 1) * j;
        p -= num_l[i] - 1;
        break;
      }
      tmp += num[j] * j;
      p -= num[j];
    }
    ans = min(ans, tmp);
  }
  printf("%d\n", ans);
  return 0;
}
