#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 20;
long long l[maxn], d[maxn], t[210][maxn], kol[210], mark[maxn], sump[maxn];
long long get(long long n, long long x) {
  long long cnt = 0, ans = 0;
  for (long long i = 0; i < 210; i++) kol[i] -= t[i][n];
  long long ind = 0;
  while (cnt < x)
    if (cnt + kol[ind] >= x) {
      ans += (x - cnt) * ind;
      break;
    } else
      ans += kol[ind] * ind, cnt += kol[ind], ind++;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  int cnt = n;
  for (long long i = 0; i < n; i++) cin >> l[i], mark[l[i]]++;
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
    kol[d[i]]++;
    t[d[i]][l[i]]++;
    sump[l[i]] += d[i];
  }
  long long sum = 0, mn = 2e8;
  for (long long i = maxn; i > 0; i--) {
    if (mark[i] > 0)
      mn = min(mn, sum + get(i, cnt - 2 * mark[i] + 1)), cnt -= mark[i];
    sum += sump[i];
  }
  cout << mn << endl;
}
