#include <bits/stdc++.h>
using namespace std;
const int N = 100005, MAX = 202;
struct Leg {
  int len, cost;
  friend bool operator<(const Leg x, const Leg y) { return x.len < y.len; }
};
Leg l[N];
int sum[N];
int c[MAX][N];
int f[N];
bool vis[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &l[i].len);
  for (int i = 0; i < n; ++i) scanf("%d", &l[i].cost);
  sort(l, l + n);
  for (int i = 0; i < n; ++i) {
    ++f[l[i].len];
    ++c[l[i].cost][l[i].len];
  }
  for (int i = N - 1; i > 0; --i) {
    f[i] += f[i + 1];
  }
  for (int i = 1; i < MAX; ++i) {
    for (int j = 1; j < N; ++j) {
      c[i][j] += c[i][j - 1];
    }
  }
  int ans = INT_MAX;
  for (int i = 0; i < n; ++i) {
    int curLen = l[i].len;
    if (vis[curLen]) continue;
    vis[curLen] = 1;
    int curFreq = f[curLen] - f[curLen + 1];
    int all = n - f[curLen];
    int total = 0;
    for (int j = 1; j < MAX; ++j) {
      total += (c[j][N - 1] - c[j][curLen]) * j;
    }
    priority_queue<pair<int, int>> q;
    for (int j = 1; j < MAX; ++j) {
      q.push(make_pair(-j, c[j][curLen - 1]));
    }
    while (!q.empty() && curFreq <= all) {
      int cost = -q.top().first, cnt = q.top().second;
      if (curFreq + cnt > all) {
        total += (all - curFreq + 1) * cost;
        all = curFreq - 1;
        break;
      }
      total += cnt * cost;
      all -= cnt;
      q.pop();
    }
    ans = min(ans, total);
  }
  printf("%d", ans);
}
