#include <bits/stdc++.h>
using namespace std;
int l[100010], d[100010], cnt[100010], cost[100010], answer[100010];
int z[205];
vector<int> v[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, j, _max = 0, m, temp, x, y, p;
  cin >> n;
  m = (n / 2) + 1;
  for (i = 0; i < n; i++) {
    cin >> l[i];
    cnt[l[i]]++;
    if (l[i] > _max) _max = l[i];
  }
  for (i = 0; i < n; i++) {
    cin >> d[i];
    cost[l[i]] += d[i];
    z[d[i]]++;
  }
  for (i = 0; i < n; i++) {
    v[l[i]].push_back(d[i]);
  }
  temp = 0;
  for (i = _max; i >= 1; i--) {
    if (cnt[i] == 0) {
      answer[i] = 1000000000;
    } else if (cnt[i] >= m) {
      answer[i] = temp;
      temp += cost[i];
      n -= cnt[i];
      m = (n / 2) + 1;
      for (j = 0; j < (int)v[i].size(); j++) z[v[i][j]]--;
    } else {
      x = n - (2 * cnt[i] - 1);
      for (j = 0; j < (int)v[i].size(); j++) z[v[i][j]]--;
      y = 0;
      for (j = 1; j <= 200; j++) {
        if (z[j] == 0) continue;
        p = min(x, z[j]);
        y += p * j;
        x -= p;
        if (x == 0) break;
      }
      answer[i] = temp + y;
      temp += cost[i];
      n -= cnt[i];
      m = (n / 2) + 1;
    }
  }
  temp = 1000000000;
  for (i = _max; i >= 1; i--) temp = min(temp, answer[i]);
  cout << temp << '\n';
  return 0;
}
