#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int cnt[maxn], n;
pair<int, int> a[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].second;
    cnt[a[i].second]++;
  }
  sort(a + 1, a + 1 + n);
  int ans = 1e9;
  int sum = 0;
  int p = n;
  for (int i = n; i > 0; i--) {
    while (p > 0 && a[p].first == a[i].first) {
      cnt[a[p].second]--;
      p--;
    }
    int cur = max(0, i + 1 - 2 * (i - p));
    int now = sum;
    for (int j = 1; j <= 200; j++) {
      now += min(cur, cnt[j]) * j;
      cur -= min(cur, cnt[j]);
    }
    ans = min(ans, now);
    sum += a[i].second;
  }
  cout << ans << endl;
  return 0;
}
