#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, e = 0;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l[i];
  vector<pair<int, int>> ld;
  for (int i = 0; i < n; i++) {
    int d;
    cin >> d;
    ld.push_back({l[i], d});
    e += d;
  }
  sort(ld.begin(), ld.end());
  ld.push_back({100001, 0});
  int te = 0, nl = 0, pl = ld[0].first, pc = 0, v = e;
  vector<int> cnt(201), ple;
  for (auto &p : ld) {
    if (p.first > pl) {
      int cur = e - te, rl = max(0, nl - (2 * pc - 1));
      for (int d = 1; d <= 200 && rl; d++) {
        int r = min(cnt[d], rl);
        cur += r * d;
        rl -= r;
      }
      if (cur < v) v = cur;
      pl = p.first;
      pc = 1;
      for (int x : ple) cnt[x]++;
      ple = {p.second};
    } else {
      pc++;
      ple.push_back(p.second);
    }
    te += p.second;
    nl++;
  }
  cout << v;
}
