#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const long double pi = acos(-1.0);
const long long inf = 1e+9;
#pragma comment(linker, "/STACK:36777216")
template <typename T>
istream &operator>>(istream &, vector<T> &);
template <typename T>
ostream &operator<<(ostream &, const vector<T> &);
void solve() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i].first);
  int D = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].second);
    D += a[i].second;
  }
  sort(a.begin(), a.end());
  vector<int> Dcnt(205);
  int ans = inf;
  for (int i = 0; i < n; i++) {
    int add = 0;
    int dt = 0;
    while (i + add < n && a[i].first == a[i + add].first) {
      dt += a[i + add].second;
      add++;
    }
    int f = D - dt;
    int needDel = max(0, i - (add - 1));
    for (int j = 0; j <= 200; j++) {
      int mn = min(Dcnt[j], needDel);
      needDel -= mn;
      f += mn * j;
    }
    ans = min(ans, f);
    D -= dt;
    add = 0;
    while (i + add < n && a[i].first == a[i + add].first) {
      Dcnt[a[i + add].second]++;
      add++;
    }
    i += add - 1;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) is >> v[i];
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) os << v[i];
  return os;
}
