#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> vec;
int cnt[maxn];
pair<int, int> suffix[maxn];
int sm[205][maxn];
pair<int, int> leg[maxn];
int MAIN() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &leg[i].first);
    vec.push_back(leg[i].first);
  }
  for (int i = 0; i < n; ++i) scanf("%d", &leg[i].second);
  sort(leg, leg + n);
  for (int i = 0; i < n; ++i) {
    int l = leg[i].first, c = leg[i].second;
    ++cnt[l];
    ++sm[c][l];
    ++suffix[l].first;
    suffix[l].second += c;
  }
  for (int c = 1; c <= 200; ++c)
    for (int l = 1; l <= 1e5; ++l) sm[c][l] += sm[c][l - 1];
  for (int l = 1e5; l >= 0; --l) {
    suffix[l].first += suffix[l + 1].first;
    suffix[l].second += suffix[l + 1].second;
  }
  sort(vec.begin(), vec.end(), greater<int>());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  int ans = 1e9;
  for (int i = 0; i < (int)vec.size(); ++i) {
    int l = vec[i];
    int cost = 0;
    cost += suffix[l + 1].second;
    int need = max(0, (n - suffix[l + 1].first) - (cnt[l] * 2 - 1));
    for (int d = 1; d <= 200; ++d) {
      if (need == 0) break;
      if (need > sm[d][l - 1]) {
        cost += d * sm[d][l - 1];
        need -= sm[d][l - 1];
      } else {
        cost += d * need;
        need = 0;
      }
    }
    ans = min(ans, cost);
  }
  printf("%d\n", ans);
  return 0;
}
int main() { return MAIN(); }
