#include <bits/stdc++.h>
using namespace std;
const int cmax = 1e5 + 8;
int n;
int cnt[cmax];
vector<pair<int, int> > l(cmax);
long long psum[cmax];
int d[202];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> l[i].first, cnt[l[i].first]++;
  for (int i = 1; i <= n; i++) cin >> l[i].second;
  sort(l.begin() + 1, l.begin() + n + 1);
  for (int i = 1; i <= n; i++) psum[i] = psum[i - 1] + l[i].second;
  long long ans = 284488937875784;
  for (int i = 1; i <= n; i++) {
    int p = i;
    while (i < n and l[i].first == l[i + 1].first) i++;
    long long t = psum[n] - psum[i];
    int x = max(0, i - 2 * cnt[l[i].first] + 1);
    for (int j = 1; j <= 200 and x > 0; j++) {
      int u = min(x, d[j]);
      x -= u;
      t += (long long)u * j;
    }
    ans = min(ans, t);
    for (int k = p; k <= i; k++) d[l[k].second]++;
  }
  cout << ans << '\n';
  return 0;
}
