#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
const int D = 200 + 1;
int n;
pair<int, int> a[N];
int cn[N];
int cd[D];
long long sum, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    cn[a[i].first]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].second;
    sum += a[i].second;
  }
  sort(a, a + n);
  int it = 0;
  ans = (long long)1e18;
  for (int i = 0; i < N && it < n; i++) {
    if (a[it].first > i) continue;
    int ln = 0;
    long long ls = 0;
    for (int j = 0; j < D; j++) {
      int cnt = min(cd[j], max((it - ln) - cn[i] + 1, 0));
      ln += cnt, ls += j * cnt;
    }
    while (it < n && a[it].first == i) {
      sum -= a[it].second;
      cd[a[it].second]++;
      it++;
    }
    ans = min(ans, ls + sum);
  }
  cout << ans;
  return 0;
}
