#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[100005];
int sum[100005];
multiset<int> s;
multiset<int>::iterator it;
int d[205];
vector<int> v;
int main() {
  int i, j, n, ans, temp, rest_count, to_cut;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &arr[i].first);
  for (i = 0; i < n; i++) scanf("%d", &arr[i].second);
  sort(arr, arr + n);
  sum[n - 1] = arr[n - 1].second;
  for (i = n - 2; i >= 0; i--) sum[i] = sum[i + 1] + arr[i].second;
  ans = INT_MAX;
  for (i = 0; i < n + 1; i++) {
    if ((i != 0 && arr[i].first != arr[i - 1].first) || (i == n)) {
      temp = sum[i];
      rest_count = i - v.size();
      to_cut = rest_count - v.size() + 1;
      for (j = 1; j <= 200; j++) {
        if (to_cut <= 0) break;
        if (d[j] >= to_cut) {
          temp += (to_cut * j);
          to_cut = 0;
        } else {
          temp += (d[j] * j);
          to_cut -= d[j];
        }
      }
      if (to_cut <= 0) ans = min(ans, temp);
      for (j = 0; j < v.size(); j++) d[v[j]]++;
      v.clear();
      v.push_back(arr[i].second);
    } else {
      v.push_back(arr[i].second);
    }
  }
  printf("%d\n", ans);
  return 0;
}
