#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
pair<int, int> a[maxn];
int n, cnt[205], cur, k, del, temp, j;
long long ans;
int min(int x, int y) { return x < y ? x : y; }
int main() {
  scanf("%d", &n);
  ans = n * 200;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].first);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].second);
    cnt[a[i].second]++;
  }
  sort(a + 1, a + n + 1);
  j = n;
  for (int i = n; i >= 1; i--) {
    while (j >= 1 && a[i].first == a[j].first) {
      cnt[a[j].second]--;
      j--;
    }
    k = i - j;
    del = max(0, i - 2 * k + 1);
    temp = cur;
    for (int p = 1; p <= 200; p++) {
      temp += min(del, cnt[p]) * p;
      del -= min(del, cnt[p]);
    }
    ans = min(ans, temp);
    cur += a[i].second;
  }
  printf("%I64d\n", ans);
  return 0;
}
