#include <bits/stdc++.h>
using namespace std;
int N, K;
pair<int, int> P[1000001];
int L[1000001], D[1000001];
int C[201];
int main(int argc, char** argv) {
  std::ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> P[i].first;
  for (int i = 1; i <= N; i++) cin >> P[i].second;
  sort(P + 1, P + 1 + N);
  for (int i = 1; i <= N; i++) {
    L[i] = P[i].first;
    D[i] = D[i - 1] + P[i].second;
  }
  int ans = 1e9;
  int l = 1;
  while (l <= N) {
    int r = l;
    while (r <= N && L[r] == L[l]) r++;
    int removed = D[N] - D[r - 1];
    int toremove = max(0, l - (r - l));
    for (int k = 1; k <= 200 && toremove; k++) {
      removed += min(C[k], toremove) * k;
      toremove -= min(C[k], toremove);
    }
    ans = min(ans, removed);
    for (int i = l; i < r; i++) C[P[i].second]++;
    l = r;
  }
  cout << ans << endl;
  return 0;
}
