#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int cal[205];
int l[maxn];
vector<int> d[maxn];
int main() {
  int n, num, t;
  cin >> n;
  memset(cal, 0, sizeof(cal));
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    d[l[i]].push_back(t);
    cal[t]++;
  }
  int ans = 0x3f3f3f3f, tt = 0;
  int m = n;
  for (int i = maxn - 1; i > 0; i--) {
    if (d[i].size() != 0) {
      int k = d[i].size(), _ans = tt;
      k = m - (k * 2 - 1);
      for (int j = 0; j < d[i].size(); j++) {
        tt += d[i][j];
        cal[d[i][j]]--;
        m--;
      }
      for (int j = 1; j <= 200 && k; j++) {
        if (cal[j]) {
          int temp;
          temp = min(cal[j], k);
          _ans += j * temp;
          k -= temp;
        }
      }
      ans = min(ans, _ans);
    }
  }
  cout << ans << endl;
  return 0;
}
