#include <bits/stdc++.h>
using namespace std;
long long sum[200000];
int v[200000];
int e[200000];
int counter[200000];
int seen[205];
vector<int> gastos[200000];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    counter[v[i]]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> e[i];
    sum[v[i]] += e[i];
    gastos[v[i]].push_back(e[i]);
  }
  for (int i = 1; i <= 100000; i++) {
    sum[i] += sum[i - 1];
  }
  long long ans = (1LL << 62);
  for (int i = 1; i <= 100000; i++) {
    long long cur = sum[100000] - sum[i];
    cur += sum[i - 1];
    int cantidad_patas_maxima = (counter[i] * 2) - 1;
    int cantidad_necesito = cantidad_patas_maxima - counter[i];
    long long sumatoria = 0;
    for (int j = 200; j >= 0 && cantidad_necesito; j--) {
      int tomar = min(cantidad_necesito, seen[j]);
      sumatoria += j * tomar;
      cantidad_necesito -= tomar;
    }
    cur -= sumatoria;
    ans = min(cur, ans);
    for (int j = 0; j < gastos[i].size(); j++) seen[gastos[i][j]]++;
  }
  cout << ans << endl;
  return 0;
}
