#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long p = 1, data = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    data = data * 10 + (ch ^ 48);
    ch = getchar();
  }
  return p * data;
}
inline long long qpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = a * r;
    a = a * a;
    b >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
void exgcd(long long a, long long b, long long &x, long long &y) {
  if (!b)
    x = 1, y = 0;
  else {
    exgcd(b, a % b, y, x);
    y -= x * (a / b);
  }
}
const int mod = 1e9 + 7, maxn = 1e5 + 5;
struct node {
  int l, w;
  friend bool operator<(node a, node b) {
    return a.l == b.l ? a.w < b.w : a.l < b.l;
  }
} a[maxn];
unordered_map<int, int> mp, pm;
int sum[maxn], num[maxn], v[205];
int main() {
  int n = read();
  for (int i = 1; i <= n; i++) a[i].l = read(), mp[a[i].l]++;
  for (int i = 1; i <= n; i++) a[i].w = read();
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i].w;
  for (int i = 1; i <= 100000; i++) num[i] = num[i - 1] + mp[i];
  long long ans = 0x3f3f3f3f3f3f3f3f;
  for (int i = 1; i <= 100000; i++) {
    if (!mp[i]) continue;
    long long now = sum[n] - sum[num[i]], m = num[i] - 2 * mp[i] + 1;
    for (int j = 1; j <= 200 && m > 0; j++) {
      if (m >= v[j])
        m -= v[j], now += v[j] * j;
      else
        now += m * j, m = 0;
    }
    ans = min(ans, now);
    for (int j = num[i - 1] + 1; j <= num[i]; j++) v[a[j].w]++;
  }
  printf("%lld\n", ans);
  return 0;
}
