#include <bits/stdc++.h>
using namespace std;
int cnt[1000], pref[100000];
pair<int, int> a[100000];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].first;
  for (int i = 0; i < n; i++) cin >> a[i].second;
  sort(a, a + n);
  pref[0] = a[0].second;
  for (int i = 1; i < n; i++) pref[i] = pref[i - 1] + a[i].second;
  int ans = 1000000000, maxlen = 0, cur = 0;
  for (int i = 0; i < n; i++) {
    int pos = i;
    cur = 0;
    while (a[i].first == a[i + 1].first) i++;
    maxlen = a[i].first;
    cur += pref[n - 1] - pref[i];
    int k = i - pos + 1, m = i + 1;
    if (m / 2 >= k) {
      for (int j = 1; j < 201; j++) {
        cur += min(m - 2 * k + 1, cnt[j]) * j;
        m -= min(m - 2 * k + 1, cnt[j]);
        if (m / 2 < k) {
          break;
        }
      }
    }
    ans = min(ans, cur);
    for (int j = pos; j <= i; j++) cnt[a[j].second]++;
  }
  cout << ans << endl;
  return 0;
}
