#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[100001];
vector<pair<int, int> > v1;
int ans = 1e9, tot;
int f1(int larger, int skip) {
  int sum = 0;
  for (vector<pair<int, int> >::reverse_iterator it = v1.rbegin();
       it != v1.rend() && skip > 0; ++it)
    if (it->second < larger) sum += it->first, skip--;
  return tot - sum;
}
int main() {
  int n;
  scanf("%d", &n);
  v1.reserve(n);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].first);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i].second), tot += p[i].second;
  for (int i = 1; i <= n; i++)
    v1.push_back(pair<int, int>(p[i].second, p[i].first));
  sort(p + 1, p + 1 + n);
  sort(v1.begin(), v1.end());
  p[0].first = -1;
  int prev = n, acc = p[n].second;
  for (int i = n - 1; i >= 0; i--) {
    if (p[i].first != p[i + 1].first) {
      ans = min(ans, f1(p[i + 1].first, prev - i - 1) - acc);
      prev = i;
      acc = 0;
    }
    acc += p[i].second;
  }
  printf("%d\n", ans);
  return 0;
}
