#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[100005];
int n, ad[201], al[100005];
int sum, ans;
void cal(int s, int f) {
  int csum = 0;
  for (int i = s; i <= f; i++) csum += p[i].second;
  int need = f - s;
  for (int i = 200; i >= 1; i--) {
    int cd = (ad[i] <= need ? ad[i] : need);
    csum += (cd * i);
    need -= cd;
  }
  for (int i = s; i <= f; i++) ad[p[i].second]++;
  ans = (ans >= csum ? ans : csum);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> al[i];
  for (int i = 0; i < n; i++) {
    int cd;
    cin >> cd;
    p[i] = make_pair(al[i], cd);
    sum += cd;
  }
  sort(p, p + n);
  for (int i = 0, s = -1; i < n; i++) {
    if (s == -1) s = i;
    if (i == n - 1 || p[i].first != p[i + 1].first) {
      cal(s, i);
      s = -1;
      continue;
    }
  }
  cout << sum - ans << endl;
  return 0;
}
