#include <bits/stdc++.h>
using namespace std;
struct node {
  int energy;
  int legs;
} ob[100010];
long long int suff[100010] = {0};
int ind[100010][2];
int cmp(const void *a, const void *b) {
  if (((struct node *)a)->legs < (((struct node *)b)->legs)) {
    return -1;
  } else if (((struct node *)a)->legs == (((struct node *)b)->legs)) {
    return 0;
  }
  return 1;
}
long long int min(long long int a, long long int b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
int up_bn(int l, int h, int x) {
  int ans, mid;
  while (l <= h) {
    mid = (l + h) / 2;
    if (ob[mid].legs > x) {
      h = mid - 1;
    } else if (ob[mid].legs == x) {
      ans = mid;
      l = mid + 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
int lw_bn(int l, int h, int x) {
  int ans, mid;
  while (l <= h) {
    mid = (l + h) / 2;
    if (ob[mid].legs > x) {
      h = mid - 1;
    } else if (ob[mid].legs == x) {
      ans = mid;
      h = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  return ans;
}
int main() {
  int n, i, j, prev;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &ob[i].legs);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &ob[i].energy);
  }
  qsort(ob, n, sizeof(ob[0]), cmp);
  prev = ob[0].legs;
  ind[prev][0] = 0;
  for (int i = 1; i < n; i++) {
    if (ob[i].legs != prev) {
      ind[prev][1] = i - 1;
      prev = ob[i].legs;
      ind[prev][0] = i;
    }
  }
  ind[prev][1] = n - 1;
  suff[n - 1] = ob[n - 1].energy;
  suff[n] = 0;
  for (i = n - 2; i >= 0; i--) {
    suff[i] = suff[i + 1] + ob[i].energy;
  }
  int cnt[210] = {0};
  long long int cost = 111111111111;
  for (int i = 0; i < n;) {
    int upp = ind[ob[i].legs][1];
    int low = ind[ob[i].legs][0];
    int len = 2 * (upp - low + 1) - 1;
    if (n - 1 - upp >= n - len) {
      cost = min(cost, suff[upp + 1]);
    } else {
      int remov = (n - len) - (n - 1 - upp);
      long long int temp = 0;
      temp += suff[upp + 1];
      int er = 1;
      while (remov > 0 && er < 201) {
        if (cnt[er] > 0) {
          if (cnt[er] >= remov) {
            temp += er * remov;
            remov = 0;
          } else {
            remov -= cnt[er];
            temp += er * cnt[er];
          }
        }
        er++;
      }
      if (remov == 0) cost = min(cost, temp);
    }
    for (j = low; j <= upp; j++) {
      cnt[ob[j].energy]++;
    }
    i = upp + 1;
  }
  printf("%lld\n", cost);
  return 0;
}
