#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 1e5 + 10;
int n, l[N], d[N], sum[N], ss, res(1e9);
pair<int, int> a[N];
vector<int> v;
multiset<int, greater<int> > st;
multiset<int, greater<int> >::iterator it;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    v.push_back(a[i].first);
  }
  for (int i = 0; i < n; i++) cin >> a[i].second;
  sort(a, a + n);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 0; i < n; i++) l[i] = a[i].first;
  for (int i = n - 1; i >= 0; i--) sum[i] = a[i].second + sum[i + 1];
  for (int i = 0; i < v.size(); i++) {
    int fst = lower_bound(l, l + n, v[i]) - l;
    int snd = upper_bound(l, l + n, v[i]) - l;
    int j = 0, s = ss + sum[snd], k = snd - fst - 1;
    for (__typeof((st).begin()) it = (st).begin(); it != (st).end(); it++) {
      if (j >= k) break;
      s -= *it;
      j++;
    }
    for (j = fst; j < snd; j++) {
      st.insert(a[j].second);
      ss += a[j].second;
    }
    res = min(res, s);
  }
  cout << res << endl;
  cin >> n;
  return 0;
}
