#include <bits/stdc++.h>
std::istream& in = std::cin;
std::ostream& out = std::cout;
const int MaxN = 100005;
const int MaxM = 205;
int n;
std::pair<int, int> arr[MaxN];
int sum[MaxN], count[MaxM];
int main() {
  std::ios_base::sync_with_stdio(false);
  out.precision(12);
  int res;
  while (in >> n) {
    for (int i = 0; i < n; i++) in >> arr[i].first;
    for (int i = 0; i < n; i++) in >> arr[i].second;
    std::sort(arr, arr + n);
    memset(count, 0, sizeof(count));
    sum[n] = 0;
    res = std::numeric_limits<int>::max();
    for (int i = n - 1; i >= 0; i--) sum[i] = sum[i + 1] + arr[i].second;
    for (int i = 0, j = 0; i < n; i = j) {
      while (j < n && arr[j].first == arr[i].first) j++;
      int now = sum[j], needed = i - (j - i) + 1;
      for (int k = 0; needed > 0 && k < MaxM; k++) {
        now += std::min(count[k], needed) * k;
        needed -= count[k];
      }
      res = std::min(res, now);
      for (int k = i; k < j; k++) count[arr[k].second]++;
    }
    out << res << std::endl;
  }
  return 0;
}
