#include <bits/stdc++.h>
using namespace std;
const int maxN = 200010, modP = 1000000007;
int d[1000], res, s[maxN], n;
struct ioi {
  int l, d;
};
ioi a[maxN];
bool cmp(ioi i, ioi j) { return i.l < j.l; }
int main() {
  cin >> n;
  res = 1000000000;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].l);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].d);
  sort(a + 1, a + n + 1, cmp);
  int l = 1, num = 0;
  for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i].d;
  for (int i = 1; i <= n + 1; ++i) {
    if (i != 1) {
      if ((a[i].l != a[i - 1].l) || (i == n + 1)) {
        int tmp = s[n] - s[i - 1], tmp_n = l - num;
        for (int j = 1; j <= 200; ++j) {
          if (tmp_n <= 0) break;
          int tmp_ = min(tmp_n, d[j]);
          tmp += tmp_ * j;
          tmp_n -= tmp_;
        }
        for (int j = l; j <= i - 1; ++j) d[a[j].d]++;
        l = i;
        num = 0;
        res = min(res, tmp);
      }
    }
    ++num;
  }
  cout << res;
  fclose(stdin);
  fclose(stdout);
}
