#include <bits/stdc++.h>
using namespace std;
int count1[200001][200];
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  vector<int> d(n);
  vector<pair<int, int> > p(n);
  vector<unsigned long> sum(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  for (int i = 0; i < n; i++) cin >> d[i];
  for (int i = 0; i < n; i++) {
    p[i] = make_pair(l[i], d[i]);
  }
  sort(p.begin(), p.end());
  sum[0] = p[0].second;
  for (int i = 1; i < n; i++) sum[i] = sum[i - 1] + p[i].second;
  vector<int> val;
  vector<int> ct;
  int c = 1;
  for (int j = 1; j <= 200; j++) {
    count1[0][j] = 0;
  }
  count1[0][p[0].second]++;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= 200; j++) {
      count1[i][j] = count1[i - 1][j];
    }
    count1[i][p[i].second]++;
    if (p[i].first == p[i - 1].first) {
      c++;
      continue;
    }
    val.push_back(p[i - 1].first);
    ct.push_back(c);
    c = 1;
  }
  val.push_back(p[n - 1].first);
  ct.push_back(c);
  int ans = sum[n - 1] - sum[ct[0] - 1];
  int m = val.size();
  int index = ct[0] - 1;
  for (int i = 1; i < m; i++) {
    int temp = sum[n - 1] - sum[index + ct[i]];
    int t = ct[i] - 1;
    int cnt = 0;
    int j = 200;
    int keep = 0;
    while (cnt < t && j > 0) {
      int add = min(count1[index][j], t - cnt);
      cnt += add;
      keep += j * add;
      j--;
    }
    temp += sum[index] - keep;
    if (temp < ans) {
      ans = temp;
    }
    index += ct[i];
  }
  cout << ans << endl;
}
