#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, c;
} a[100005];
int b, c, d, e, f[205], g, h, i, j, k, l, m, n, s[100005];
inline bool cmp(node a, node b) { return a.l < b.l; }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i].l);
  for (i = 1; i <= n; i++) scanf("%d", &a[i].c);
  sort(a + 1, a + 1 + n, cmp);
  for (i = 1; i <= n; i++) s[i] = s[i - 1] + a[i].c;
  h = s[n];
  for (i = 1; i <= n; i = j + 1) {
    for (j = i; a[j + 1].l == a[i].l; j++)
      ;
    k = j - i + 1;
    g = s[n] - s[j];
    for (l = 1, d = i - k; l <= 200 && d > 0; l++) {
      if (d > f[l]) {
        d = d - f[l];
        g = g + f[l] * l;
      } else {
        g = g + d * l;
        d = 0;
      }
    }
    h = min(h, g);
    for (l = i; l <= j; l++) f[a[l].c]++;
  }
  printf("%d\n", h);
  return 0;
}
