#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, d;
  bool operator<(const node &a) const {
    if (l == a.l) return d < a.d;
    return l < a.l;
  }
} s[100100];
int len[100100], sum[100100];
int num[100100];
int tot[100100], h[210];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i].l);
    tot[s[i].l]++;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i].d);
    len[s[i].l] += s[i].d;
  }
  for (int i = 100000; i >= 1; i--) {
    if (tot[i] == 0) {
      sum[i] = sum[i + 1];
      num[i] = num[i + 1];
    } else {
      sum[i] = sum[i + 1] + len[i];
      num[i] = num[i + 1] + tot[i];
    }
  }
  sort(s + 1, s + n + 1);
  int ans = (1 << 30) - 1;
  int cnt = 1;
  for (int i = 1; i <= 100000; i++) {
    if (tot[i] == 0) continue;
    int t = sum[i + 1];
    int x = n - num[i + 1];
    if (tot[i] * 2 > x)
      ans = min(ans, t);
    else {
      int y = x - 2 * tot[i] + 1;
      while (cnt <= n && s[cnt].l < i) h[s[cnt++].d]++;
      int tmp = 0;
      for (int j = 1; j <= 200; j++) {
        if (h[j] == 0) continue;
        if (y - h[j] >= 0) {
          y -= h[j];
          tmp += j * h[j];
        } else {
          tmp += y * j;
          y = 0;
          break;
        }
      }
      ans = min(ans, tmp + t);
    }
  }
  cout << ans << endl;
  return 0;
}
