#include <bits/stdc++.h>
using namespace std;
long long n;
long long visited[100010];
pair<long long, long long> a[100010];
long long cst[100100];
long long cnt[100010];
long long xx[210];
int main() {
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i].first);
    cnt[a[i].first]++;
  }
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i].second);
    cst[a[i].first] += a[i].second;
  }
  for (int i = 100000; i >= 0; i--) cst[i] = cst[i + 1] + cst[i];
  sort(a, a + n);
  long long dap = 1234999999999999;
  for (int i = 0; i < n; i++) {
    long long gap = 0;
    if (!visited[a[i].first]) {
      visited[a[i].first] = 1;
      gap = cst[a[i].first + 1];
      long long ch = cnt[a[i].first];
      long long ch1 = i;
      for (int y = 0; y <= 200; y++) {
        if (xx[y]) {
          gap += (y * xx[y]);
          ch1 -= xx[y];
        }
        if (ch1 < ch) {
          gap -= (y * (ch - ch1 - 1));
          break;
        }
      }
      dap = min(dap, gap);
    }
    xx[a[i].second]++;
  }
  printf("%lld\n", dap);
}
