#include <bits/stdc++.h>
using namespace std;
void OUT_TST(string s, istream_iterator<string> it) { cerr << s; }
template <typename T, typename... Args>
void OUT_TST(string s, istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " ";
  OUT_TST(s, ++it, args...);
}
template <class T>
void rd(T& ret) {
  ret = 0;
  bool ok = 0, u = 0;
  for (;;) {
    int c = getchar();
    if (c >= '0' && c <= '9')
      ret = (ret << 3) + (ret << 1) + c - '0', ok = 1;
    else if (c == '-')
      u = 1;
    else if (ok) {
      if (u) ret *= -1;
      return;
    }
  }
}
long long powmod(long long p, long long n, long long mod) {
  long long ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * p % mod;
    p = p * p % mod;
  }
  return ret;
}
template <class T>
bool chmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool chmax(T& a, const T& b) {
  return b > a ? a = b, 1 : 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int stk[55], t, n;
vector<int> sum[55];
double dp[52][27][5005];
pair<int, int> an[55];
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d", &an[i].first);
  for (int i = (0); i < (n); i++) scanf("%d", &an[i].second);
  sort(an, an + n, greater<pair<int, int> >());
  t = 0;
  stk[t++] = 1e9;
  for (int i = (0); i < (n); i++) {
    if (an[i].first != stk[t - 1]) {
      stk[t++] = an[i].first;
    }
    sum[t - 1].push_back(an[i].second);
  }
  int up = 0, cnt_sum = 0;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n / 2 + 1); j++)
      for (int k = (0); k < (5005); k++) dp[i][j][k] = 2e9;
  dp[0][0][0] = 0;
  long long ans = 1ll << 60;
  for (int i = (0); i < (t - 1); i++) {
    int nup = up;
    for (int j = (0); j < (cnt_sum / 2 + 1); j++) {
      for (int k = (0); k < (up + 1); k++)
        if (dp[i][j][k] < 1e9) {
          int tsum = 0, power_sum = 0, cnt = ((int)(sum[i + 1]).size());
          for (int first = (0); first < (cnt + 1); first++) {
            if (cnt_sum - j * 2 >= cnt - first) {
              if (chmin(dp[i + 1][j + cnt - first][k + tsum],
                        (dp[i][j][k] * k + power_sum) / (k + tsum)) &&
                  i + 1 == 2 && j + cnt - first == 2 && k + tsum == 2) {
              }
              chmax(nup, k + tsum);
              if (i == t - 2) {
                if (chmin(ans,
                          long long(ceil(
                              1000 * dp[i + 1][j + cnt - first][k + tsum])))) {
                }
              }
            }
            if (first < cnt) {
              tsum += sum[i + 1][first];
              power_sum += stk[i + 1];
            }
          }
        }
    }
    cnt_sum += ((int)(sum[i + 1]).size());
    up = nup;
  }
  cout << ans << endl;
  return 0;
}
