#include <bits/stdc++.h>
using namespace std;
int l[100010], d[100010];
vector<int> adjl[100010];
int costcnt[220];
int main() {
  std::ios_base::sync_with_stdio(false);
  ;
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> l[i];
  }
  int tot = 0;
  for (int i = 0; i <= n - 1; i++) {
    cin >> d[i];
    tot += d[i];
    costcnt[d[i]]++;
  }
  for (int i = 0; i <= n - 1; i++) {
    adjl[l[i]].push_back(d[i]);
  }
  int ans = 1000000000;
  int borocost = 0;
  for (int i = 100000; i >= 1; i--) {
    if (adjl[i].empty()) continue;
    int cnt = adjl[i].size() - 1;
    int tmpbc = borocost;
    for (int j = 0; j <= (int)adjl[i].size() - 1; j++) {
      costcnt[adjl[i][j]]--;
      tot -= adjl[i][j];
      borocost += adjl[i][j];
    }
    int tmpcnt = 0;
    int negcost = 0;
    for (int j = 200; j >= 0; j--) {
      if (tmpcnt + costcnt[j] > cnt) {
        negcost += (cnt - tmpcnt) * j;
        break;
      }
      tmpcnt += costcnt[j];
      negcost += costcnt[j] * j;
    }
    ans = min(ans, tot - negcost + tmpbc);
  }
  cout << ans << "\n";
  return 0;
}
