#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  pair<int, int> legs[100002];
  int weight_n[210] = {0};
  int tmp;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &legs[i].first);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &legs[i].second);
    weight_n[legs[i].second]++;
  }
  sort(legs, legs + n);
  int energy = 0, least_energy = 20000002;
  int i, j;
  int weight_to_remove = 0;
  for (i = n - 1; i >= 0; i = j) {
    energy = weight_to_remove;
    for (j = i; j >= 0 && legs[j].first == legs[i].first; --j) {
      weight_to_remove += legs[j].second;
      weight_n[legs[j].second]--;
    }
    int n_to_remove = (j + 1) - (i - j) + 1;
    for (int w = 1; w <= 200 && n_to_remove > 0; ++w) {
      tmp = min(weight_n[w], n_to_remove);
      energy += tmp * w;
      n_to_remove -= tmp;
    }
    if (energy < least_energy) least_energy = energy;
  }
  printf("%d", least_energy);
  exit(0);
}
