#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int INF = 2147483646;
long long INF64 = 9223372036854775807;
long double EPS = 0.000000000001;
long double PI = 3.14159265358979310000;
pair<long long, long long> a[123456];
long long dp[1234];
int n;
bool comp(pair<long long, long long> xx, pair<long long, long long> yy) {
  return xx.first > yy.first;
}
long long get(long long first) {
  long long i;
  long long ss = 0;
  if (first > 0)
    for (i = 1; i <= 200; i++)
      if (dp[i] >= first) {
        ss += i * first;
        first = 0;
        break;
      } else {
        ss += dp[i] * i;
        first -= dp[i];
      }
  if (first > 0)
    return -1;
  else
    return ss;
}
int main() {
  int i, j, n;
  long long mini = INF64, sum = 0, ss = 0, k = 0, kk, first, s1 = 0, qq;
  qq = 0;
  cin >> n;
  for (int i = 0; i < int(n); i++) scanf("%d", &a[i].first);
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &a[i].second);
    dp[a[i].second]++;
  }
  sort(a, a + n, comp);
  for (i = 0; i < n; i++) {
    ss += a[i].second;
    dp[a[i].second]--;
    k++;
    if (i + 1 < n && a[i].first == a[i + 1].first) continue;
    first = get(n - i - 1 - k + 1);
    if (first != -1) mini = min(mini, sum + first);
    sum += ss;
    ss = 0;
    k = 0;
  }
  cout << mini;
  return 0;
}
