#include <bits/stdc++.h>
using namespace std;
int cnt[300];
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > v(n);
  for (int i = 0; i < int(n); i++) scanf("%d", &v[i].first);
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &v[i].second);
    cnt[v[i].second]++;
  }
  sort(v.begin(), v.end());
  int idx = n - 1, sol = INFINITY, acc = 0;
  while (idx >= 0) {
    int j = idx, acc_aux = 0;
    while (j >= 0 && v[j].first == v[idx].first) {
      acc_aux += v[j].second;
      cnt[v[j].second]--;
      j--;
    }
    int lr = idx + 1, lm = idx - j, lg = 2 * lm - 1;
    int c = 0, pre_sol = acc;
    while (lg < lr) {
      pre_sol += min(cnt[c], lr - lg) * c;
      lr -= min(cnt[c], lr - lg);
      c++;
    }
    sol = min(sol, pre_sol);
    idx = j;
    acc += acc_aux;
  }
  printf("%d\n", sol);
}
