#include <bits/stdc++.h>
using namespace std;
vector<int> v[207];
int a[100007];
int b[100007];
int aa[100007];
int bb[100007];
int aaa[100007];
int bbb[100007];
int main() {
  int m;
  scanf("%d", &m);
  int i, j;
  for (i = 0; i < m; i++) scanf("%d", a + i), aa[a[i]]++;
  for (i = 0; i < m; i++)
    scanf("%d", b + i), aaa[a[i]] = aaa[a[i]] + b[i], v[b[i]].push_back(a[i]);
  for (i = 1; i <= 200; i++)
    if (v[i].size()) sort(v[i].begin(), v[i].end());
  for (i = 100000; i >= 0; i--)
    bb[i] = bb[i + 1] + aa[i], bbb[i] = bbb[i + 1] + aaa[i];
  long long int ans = 1e9;
  long long int anss;
  for (i = 1; i <= 100000; i++) {
    if (aa[i]) {
      int tem = m - 2 * aa[i] + 1;
      tem = tem - bb[i + 1];
      anss = bbb[i + 1];
      if (tem <= 0)
        ans = min(ans, anss);
      else {
        for (j = 1; j <= 200; j++) {
          if (v[j].empty()) continue;
          int index = lower_bound(v[j].begin(), v[j].end(), i) - v[j].begin();
          if (index >= tem)
            anss = anss + j * tem, tem = 0;
          else
            anss = anss + j * index, tem = tem - index;
        }
        if (!tem) ans = min(ans, anss);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
