#include <bits/stdc++.h>
using namespace std;
int n, cost[205], frec[100005], costs[205][100005];
vector<int> num;
pair<int, int> leg[100005];
int main() {
  memset(costs, 0, sizeof costs);
  int sum = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &leg[i].first);
  for (int i = 0; i < n; i++) {
    scanf("%d", &leg[i].second);
    sum += leg[i].second;
    costs[leg[i].second][leg[i].first]++;
  }
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  sort(leg, leg + n);
  memset(frec, 0, sizeof frec);
  num.clear();
  for (int i = 0; i < n; i++) {
    if (frec[leg[i].first] == 0) num.push_back(i);
    frec[leg[i].first]++;
  }
  int maxi = 0;
  memset(cost, 0, sizeof cost);
  for (int i = 0; i < num.size(); i++) {
    int lim = frec[leg[num[i]].first] - 1;
    if (lim == 0) {
      cost[leg[num[i]].second]++;
      maxi = max(maxi, leg[num[i]].second);
      continue;
    } else {
      int tmp = 0;
      for (int j = 200; j > 0; j--)
        if (lim >= cost[j]) {
          tmp += cost[j] * j;
          lim -= cost[j];
        } else {
          tmp += lim * j;
          break;
        }
      for (int j = 1; j <= 200; j++) {
        tmp += costs[j][leg[num[i]].first] * j;
        cost[j] += costs[j][leg[num[i]].first];
      }
      maxi = max(maxi, tmp);
    }
  }
  cout << sum - maxi << endl;
}
