#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const int MAXN = 1e5 + 10;
int n;
int sum = 0;
pair<int, int> a[200000];
int col[MAXN];
int cost[300];
int ans = 2000000007;
inline bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first < b.first) return true;
  if (a.first == b.first) return a.second > b.second;
  return false;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first, col[a[i].first]++;
  for (int i = 1; i <= n; i++) cin >> a[i].second, cost[a[i].second]++;
  sort(a + 1, a + n + 1);
  if (n == 1) {
    cout << 0;
    return 0;
  }
  if (n == 2) {
    if (a[1].first != a[2].first)
      cout << min(a[1].second, a[2].second);
    else
      cout << 0;
    return 0;
  }
  a[0].first = 2000000007;
  int s = 0;
  for (int i = n; i; i--) {
    s += a[i].second;
    cost[a[i].second]--;
    if (a[i].first != a[i - 1].first) {
      int c = 0, del = max(0, i - col[a[i].first]);
      for (int j = 1; j <= 200; j++) {
        int r = min(del, cost[j]);
        c += j * r, del -= r;
        if (!del) break;
      }
      ans = min(ans, sum + c);
      sum += s, s = 0;
    }
  }
  cout << ans;
}
