#include <bits/stdc++.h>
unsigned L[111111], D[111111], N[111111], C[222];
int F(const void* x, const void* y) {
  return (int)(L[*(unsigned*)x] - L[*(unsigned*)y]);
}
int main() {
  unsigned n, i = -1, j, k, r = -1, p = 0, q, s;
  for (scanf("%u", &n); ++i < n; N[i] = i) scanf("%u", L + i);
  for (i = -1; ++i < n; ++C[D[i]]) scanf("%u", D + i);
  for (qsort(N, n, sizeof(unsigned), F); n; n = s, p += q) {
    for (i = L[N[s = n - 1]], --C[q = D[N[s]]]; s-- && i == L[N[s]]; q += j)
      --C[j = D[N[s]]];
    if ((i = ((n - (++s)) << 1) - 1) > n) i = n;
    for (k = n - i, j = 0, i = -1; C[++i] < k; j += C[i] * i) k -= C[i];
    if (r > (j += k * i + p)) r = j;
  }
  printf("%u\n", r);
  return 0;
}
