#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infll = 0x3f3f3f3f3f3f3f3fLL;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
multiset<int, greater<int> > costs;
multiset<int>::iterator it;
vector<int> cost[300005];
int l[300005];
int main() {
  int n = read(), tot = 0;
  for (int i = 1; i <= n; i++) l[i] = read();
  for (int i = 1; i <= n; i++) {
    int d = read();
    costs.insert(d);
    tot += d;
    cost[l[i]].push_back(d);
  }
  int ans = tot;
  for (int i = 100000; i >= 1; i--) {
    if (!cost[i].empty()) {
      for (int j = 0; j < cost[i].size(); j++) {
        costs.erase(costs.find(cost[i][j]));
        tot -= cost[i][j];
      }
      int num = 0;
      int sum = 0;
      for (it = costs.begin(); it != costs.end(); it++) {
        if (num == cost[i].size() - 1) break;
        num++;
        sum += *it;
      }
      ans = min(ans, tot - sum);
      for (int j = 0; j < cost[i].size(); j++) tot += cost[i][j];
    }
  }
  cout << ans << endl;
}
