#include <bits/stdc++.h>
using namespace std;
int n, mn, d[205] = {0}, sum = 0;
pair<int, int> a[100015];
void read() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i].first);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i].second);
    sum += a[i].second;
  }
}
void add(int first, int last) {
  for (int i = first; i < last; ++i) ++d[a[i].second];
}
int low(int num) {
  int sum1 = 0;
  for (int i = 0; num > 0;) {
    sum1 += i * min(d[i], num);
    num -= min(d[i], num);
    ++i;
  }
  return sum1;
}
int main() {
  read();
  sort(a, a + n);
  mn = 1000000000;
  int st = 0, en = 1, sumeq = a[0].second;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i].first == a[i + 1].first) {
      sumeq += a[en].second;
      ++en;
    } else {
      mn = min(mn, sum - sumeq + low(2 * st - en + 1));
      add(st, en);
      sum -= sumeq;
      sumeq = a[en].second;
      st = en;
      ++en;
    }
  }
  mn = min(mn, sum - sumeq + low(2 * st - en + 1));
  cout << mn;
}
