#include <bits/stdc++.h>
using namespace std;
pair<long long int, long long int> a[400000];
long long ans[400000], d[400000], ct[400000];
int main() {
  std::ios::sync_with_stdio(false);
  long long int n, j, k, l, t, y, q, m, cum, temp, tc, req, over, total, an;
  int i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i].first;
  }
  for (i = 0; i < n; i++) {
    cin >> a[i].second;
  }
  sort(a, a + n);
  cum = 0;
  temp = 0;
  tc = 0;
  for (i = n - 1; i >= 1; i--) {
    if (a[i].first != a[i - 1].first) {
      tc++;
      temp = temp + a[i].second;
      ans[i] = cum;
      cum = cum + temp;
      temp = 0;
      ct[i] = tc;
      tc = 0;
    } else {
      temp = temp + a[i].second;
      tc++;
    }
  }
  tc++;
  ans[0] = cum;
  ct[0] = tc;
  long long int mini = 200000000;
  for (i = 0; i < n; i++) {
    if (ct[i] != 0) {
      an = ans[i];
      req = ct[i] / 2;
      req++;
      req = i - ct[i] + 1;
      over = 0;
      total = 0;
      int err = i;
      for (i = 1; i <= 200; i++) {
        if (req <= 0) {
          break;
        }
        if (over == req) {
          break;
        }
        if (over + d[i] >= req) {
          total = total + (req - over) * i;
          over = req;
        } else {
          total = total + d[i] * i;
          over = over + d[i];
        }
      }
      i = err;
      an = an + total;
      mini = min(mini, an);
      d[a[i].second]++;
    } else {
      d[a[i].second]++;
    }
  }
  cout << mini << endl;
  return 0;
}
