#include <bits/stdc++.h>
using namespace std;
struct dat {
  long long pro, pow;
} a[75];
long long dp[75][75], n, val[75];
bool cmp(dat a, dat b) {
  if (a.pow == b.pow) return a.pro > b.pro;
  return a.pow > b.pow;
}
bool check(long long three) {
  long long i, j, q, k, nrp, it, it2;
  memset(dp, 127, sizeof(dp));
  i = 1;
  dp[1][0] = 0;
  while (i <= n) {
    q = i;
    while (a[q].pow == a[i].pow) q++;
    memset(val, 127, sizeof(val));
    val[0] = 0;
    nrp = q - i;
    for (j = 1; j <= nrp; j++)
      val[j] = val[j - 1] + a[j + i - 1].pow - three * a[j + i - 1].pro;
    for (j = i; j < q; j++) {
      for (k = 0; k <= q; k++) {
        for (it = 0; it <= nrp && k + nrp - 2 * it >= 0; it++) {
          it2 = k + nrp - 2 * it;
          if (it2 >= nrp - it)
            dp[q][k] = min(dp[q][k], dp[i][k + nrp - 2 * it] + val[it]);
        }
      }
    }
    i = q;
  }
  long long ans = dp[n + 1][0];
  for (i = 1; i <= n; i++) ans = min(ans, dp[n + 1][i]);
  if (ans > 0) return false;
  return true;
}
int main() {
  long long i, st, dr, mij, act;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i].pow;
    a[i].pow = a[i].pow * 1000;
  }
  for (i = 1; i <= n; i++) cin >> a[i].pro;
  sort(a + 1, a + n + 1, cmp);
  st = 0;
  dr = a[1].pow;
  while (st <= dr) {
    mij = (st + dr) / 2;
    act = check(mij);
    if (act == 1)
      dr = mij - 1;
    else
      st = mij + 1;
  }
  cout << st;
  return 0;
}
