#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  pair<int, int> in[100005];
  for (int i = 0; i < n; i++) {
    scanf("%d", &in[i].first);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &in[i].second);
  }
  sort(in, in + n);
  int suffix[100005];
  memset(suffix, 0, sizeof suffix);
  suffix[n - 1] = in[n - 1].second;
  for (int i = n - 2; i >= 0; i--) {
    suffix[i] = in[i].second + suffix[i + 1];
  }
  int count[250];
  memset(count, 0, sizeof count);
  int ans = 2 * 1e9;
  int now = -1, streak = 0;
  for (int i = 0; i < n; i++) {
    if (now != in[i].first) {
      int x = i - 1;
      for (; x >= i - streak - 1; x--) count[in[x].second]++;
      streak = 0;
      now = in[i].first;
    } else {
      streak++;
    }
    int cur = suffix[i + 1];
    int lower = i - streak;
    if (streak <= lower) {
      int remove = lower - streak;
      for (int d = 1; d <= 200; d++) {
        int temp = min(remove, count[d]);
        cur += temp * d;
        remove -= temp;
      }
    }
    ans = min(ans, cur);
  }
  printf("%d\n", ans);
  return 0;
}
