#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int Scan() {
  int res = 0, ch, flag = 0;
  if ((ch = getchar()) == '-')
    flag = 1;
  else if (ch >= '0' && ch <= '9')
    res = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + ch - '0';
  return flag ? -res : res;
}
int l[100000 + 5];
int d[100000 + 5];
int cnt[205];
int sum[100000 + 5];
int sum2[100000 + 5];
vector<int> v[100000 + 5];
int main() {
  int n;
  scanf("%d", &(n));
  int L = 0;
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &(l[i]));
    if (l[i] > L) L = l[i];
  }
  int D = 0;
  for (int i = 0; i < (n); ++i) {
    scanf("%d", &(d[i]));
    if (d[i] > D) D = d[i];
  }
  for (int i = 0; i < (n); ++i) v[l[i]].push_back(d[i]);
  sum[100001] = 0;
  sum2[100001] = 0;
  for (int i = 100000; i >= 0; i--) {
    int tmp = 0;
    if (v[i].size()) {
      for (int j = 0; j < (v[i].size()); ++j) tmp += v[i][j];
    }
    sum[i] = sum[i + 1] + tmp;
    sum2[i] = sum2[i + 1] + v[i].size();
  }
  int ans = INT_MAX;
  memset((cnt), 0, sizeof((cnt)));
  for (int i = 1; i < (L + 1); ++i)
    if (v[i].size()) {
      int now = 0;
      now += sum[i + 1];
      int sz = v[i].size();
      int delta = n - 2 * (sz - 1);
      delta -= sum2[i + 1];
      delta -= 1;
      while (delta > 0) {
        for (int j = 1; j < (D + 1); ++j) {
          int t = min(delta, cnt[j]);
          now += t * j;
          delta -= t;
        }
      }
      for (int j = 0; j < (v[i].size()); ++j) {
        cnt[v[i][j]]++;
      }
      ans = min(now, ans);
    }
  printf("%d\n", ans);
  return 0;
}
