#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100 * 1000 + 10;
int n, dnm[Maxn];
pair<int, int> arr[Maxn];
vector<int> ans;
multiset<int> s;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &arr[i].first);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i].second);
    sum += arr[i].second;
  }
  sort(arr, arr + n);
  long long sum2 = 0, cnt = 0;
  int Min = 200 * Maxn;
  for (int i = 0; i < n; i++) {
    if (arr[i].first == arr[i + 1].first) {
      cnt++;
      sum2 += arr[i].second;
    } else {
      cnt++;
      sum2 += arr[i].second;
      int k = sum - sum2;
      set<int>::iterator it = s.begin();
      for (int i = 0; i < s.size() && i < cnt - 1; i++) {
        k += *it;
        it++;
      }
      if (k < Min) Min = k;
      int j = 0;
      while (j < cnt) {
        s.insert(-1 * arr[i - j].second);
        j++;
      }
      cnt = 0;
      sum2 = 0;
    }
  }
  cout << Min << endl;
  return 0;
}
