#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int INF = 1 << 30;
const int N = 100000 + 10;
struct Node {
  int l, d;
  bool operator<(const Node &rhs) const { return l < rhs.l; }
} a[N];
int prefix[N], suffix[N], c[N];
void input(int &x) {
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  x = 0;
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
}
int main() {
  int n, i, j, ans, k, total;
  while (scanf("%d", &n) != EOF) {
    total = 0;
    for (i = 0; i < n; ++i) input(a[i].l);
    for (i = 0; i < n; ++i) input(a[i].d);
    sort(a, a + n);
    for (i = 0; i < n; ++i) prefix[i] = suffix[i] = a[i].d;
    for (i = 1; i < n; ++i) prefix[i] += prefix[i - 1];
    for (i = n - 2; i >= 0; --i) suffix[i] += suffix[i + 1];
    i = 0;
    ans = INF;
    while (i < n) {
      int tmp = a[i].l;
      j = i;
      while (i < n && a[i].l == tmp) i++;
      int cnt = i - j;
      tmp = 0;
      if (i < n) tmp = suffix[i];
      int t = total;
      for (k = 1; k <= 200; ++k) {
        if (t < cnt) break;
        if (t - c[k] >= cnt - 1) {
          tmp += c[k] * k;
          t -= c[k];
        } else {
          tmp += k * (t - cnt + 1);
          break;
        }
      }
      for (k = j; k < i; ++k) {
        c[a[k].d]++;
        total++;
      }
      ans = min(ans, tmp);
    }
    printf("%d\n", ans);
  }
  return 0;
}
