#include <bits/stdc++.h>
const int MAX_N = 100000 + 5;
const int INF = ~0U >> 1;
std::pair<int, int> p[MAX_N];
int sum[MAX_N];
int sum2[MAX_N];
int n;
std::multiset<int> st;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &p[i].first);
  for (int i = 0; i < n; ++i) scanf("%d", &p[i].second);
  std::sort(p, p + n);
  for (int i = n - 1; i >= 0; --i) sum[i] = sum[i + 1] + p[i].second;
  sum2[0] = p[0].second;
  for (int i = 1; i < n; ++i) sum2[i] = sum2[i - 1] + p[i].second;
  int ans = INF;
  for (int i = 0; i < n; ++i) {
    if (i == 0 || p[i].first != p[i - 1].first) {
      int cnt = 0, j = i;
      while (j < n && p[j].first == p[i].first) j++, ++cnt;
      if (cnt > j / 2)
        ans = std::min(ans, sum[j]);
      else {
        std::multiset<int>::iterator it = st.end();
        --it;
        int tt = 0;
        cnt--;
        while (cnt--) tt += *(it--);
        ans = std::min(ans, sum2[i - 1] - tt + sum[j]);
      }
      while (i < j) st.insert(p[i++].second);
      --i;
    }
  }
  printf("%d\n", ans);
}
