#include <bits/stdc++.h>
using namespace std;
int freq[201];
int freq2D[201][100001];
int arr[100001], lenFreq[100001];
int sum[100001], accFreq[100001];
int main() {
  int n, mx = -1;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", arr + i);
    ++lenFreq[arr[i]];
    mx = max(mx, arr[i]);
  }
  int d, mxD = -1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d);
    ++freq[d];
    ++freq2D[d][arr[i]];
    mxD = max(mxD, d);
  }
  for (int i = mx; i >= 1; --i) {
    int accum = 0;
    for (int j = 1; j <= mxD; ++j) accum += freq2D[j][i] * j;
    sum[i - 1] += sum[i] + accum;
    accFreq[i - 1] += accFreq[i] + lenFreq[i];
  }
  for (int i = mx; i >= 1; --i) {
    for (int j = mxD; j >= 1; --j) {
      freq2D[j][i - 1] += freq2D[j][i];
    }
  }
  int ans = INT_MAX;
  for (int i = mx; i >= 1; --i) {
    if (!lenFreq[i]) continue;
    int newSz = n - accFreq[i];
    int cost = sum[i];
    int sz = (lenFreq[i] * 2) - 1;
    int rem = newSz - sz;
    if (rem <= 0) {
      ans = min(ans, cost);
      continue;
    }
    for (int j = 1; j <= mxD; ++j) {
      if (!freq[j]) continue;
      int available = freq[j] - freq2D[j][i];
      if (available >= rem) {
        cost += rem * j;
        rem = 0;
        break;
      } else
        rem -= available, cost += available * j;
    }
    if (!rem) ans = min(ans, cost);
  }
  printf("%d\n", ans);
  return 0;
}
