#include <bits/stdc++.h>
using namespace std;
int main() {
  int len[100005];
  int i, n, j;
  int energy[100005];
  int suff_sum[100005];
  int cnt_eng[205];
  vector<pair<int, int> > legs;
  memset(cnt_eng, 0, 205 * sizeof(int));
  memset(suff_sum, 0, 100005 * sizeof(int));
  cin >> n;
  for (i = 0; i < n; i++) cin >> len[i];
  for (i = 0; i < n; i++) cin >> energy[i];
  if (n == 1) {
    cout << "0" << endl;
    return 0;
  }
  if (n == 2) {
    if (len[0] == len[1])
      cout << "0" << endl;
    else
      cout << min(energy[0], energy[1]) << endl;
    return 0;
  }
  for (i = 0; i < n; i++) legs.push_back(make_pair(len[i], energy[i]));
  sort(legs.begin(), legs.end());
  for (int i = n - 1; i >= 0; i--) {
    suff_sum[i] = suff_sum[i + 1] + legs[i].second;
  }
  int min_energy = 1000000007;
  int curr = 0;
  int maxlen = legs[0].first;
  int curr_cnt = 1;
  int first = 0;
  int last = 0;
  for (i = 1; i < n; i++) {
    if (legs[i].first == maxlen && i != n - 1) {
      curr_cnt++;
      last = i;
    } else {
      last = i - 1;
      int leg_cnt = i - curr_cnt;
      int energy = 0;
      energy = suff_sum[i];
      if (i == n - 1 && legs[i].first == maxlen) {
        curr_cnt++;
        leg_cnt = i - curr_cnt + 1;
        energy = suff_sum[i + 1];
        last = i;
      }
      j = 1;
      while (curr_cnt <= leg_cnt) {
        int x = leg_cnt - curr_cnt + 1;
        if (cnt_eng[j] != 0) {
          int y = min(x, cnt_eng[j]);
          energy += y * j;
          leg_cnt -= y;
        }
        j++;
      }
      curr_cnt = 1;
      maxlen = legs[i].first;
      min_energy = min(min_energy, energy);
      for (int k = first; k <= last; k++) {
        cnt_eng[legs[k].second]++;
      }
      first = i;
    }
  }
  if (legs[n - 1].first != legs[n - 2].first) {
    int energy = suff_sum[0] - legs[n - 1].second;
    min_energy = min(energy, min_energy);
  }
  cout << min_energy << endl;
  return 0;
}
