#include <bits/stdc++.h>
using namespace std;
int l[100100];
int d[100100];
map<int, vector<int> > p;
int cntd[202] = {0};
int main(int argc, char** argv) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> 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++) {
    cntd[d[i]]++;
    p[l[i]].push_back(d[i]);
  }
  int sumcnt = 0;
  int sumval = 0;
  int ans = 1e9;
  int m = n;
  for (map<int, vector<int> >::reverse_iterator it = p.rbegin(); it != p.rend();
       it++) {
    int j = 0;
    for (int i = 0; i < it->second.size(); i++) {
      cntd[it->second[i]]--;
    }
    j = 0;
    int need = m - (2 * (it->second.size())) + 1;
    int deleted = 0;
    while (j <= 201 && need > 0) {
      if (cntd[j] != 0) {
        deleted += ((min(need, cntd[j])) * j);
        need -= min(need, cntd[j]);
      }
      j++;
    }
    ans = min(ans, sumval + deleted);
    m -= it->second.size();
    for (int i = 0; i < it->second.size(); i++) {
      sumval += (it->second[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
