#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
long long fre[N];
vector<long long> cost[N];
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i], fre[a[i]]++;
  long long c[n];
  for (long long i = 0; i < n; ++i) cin >> c[i], cost[a[i]].push_back(c[i]);
  long long cur[202];
  memset(cur, 0, sizeof cur);
  for (long long i = 0; i < n; ++i) cur[c[i]]++;
  long long curCost = 0;
  long long removed = 0;
  long long ans = 1e15;
  for (long long i = 100000; i >= 1; --i) {
    long long x = fre[i];
    if (x == 0) continue;
    long long tot = n - removed;
    long long toRemove = tot - (x * 2 - 1);
    for (auto cx : cost[i]) cur[cx]--;
    if (toRemove <= 0) {
      ans = min(ans, curCost);
      continue;
    }
    long long val = 0;
    for (long long j = 1; j <= 200; ++j) {
      if (cur[j] >= toRemove) {
        val += j * toRemove;
        toRemove = 0;
        break;
      } else
        val += cur[j] * j, toRemove -= cur[j];
    }
    ans = min(ans, val + curCost);
    for (auto cx : cost[i]) curCost += cx, removed++;
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
}
