#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
struct qwq {
  int a, b, rnk;
  double v;
} x[55];
int n, cnt[55], pre[55], num[55], sz;
double f[55][55], p[55], W[55][55];
bool cmp(const qwq &x, const qwq &y) {
  return (x.a == y.a) ? x.v > y.v : x.a > y.a;
}
double check(double tmp) {
  double tot = 0, ans = 0;
  int i, j, k;
  for (i = 1; i <= n; ++i) {
    x[i].v = (double)x[i].a - tmp * x[i].b;
    tot += x[i].v;
  }
  sort(x + 1, x + n + 1, cmp);
  memset(f, 0xc0, sizeof(f));
  memset(num, 0, sizeof(num));
  for (i = 1; i < sz; ++i) W[i][0] = 0;
  for (i = 1; i <= n; ++i)
    W[x[i].rnk][++num[x[i].rnk]] = W[x[i].rnk][num[x[i].rnk] - 1] + x[i].v;
  ans = f[0][0];
  if (sz == 1) return tot - W[sz][num[1]];
  for (int j = 0; j <= min(num[sz], num[sz - 1]); ++j)
    f[sz - 1][j] = W[sz - 1][j];
  for (i = sz - 2; i >= 1; --i) {
    for (j = 0; j <= pre[sz - 1] - pre[i]; ++j)
      for (k = 0; k <= num[i]; ++k)
        if (n - pre[i] - 2 * j >= k)
          f[i][j + k] = max(f[i + 1][j] + W[i][k], f[i][j + k]);
  }
  for (i = 0; i <= pre[sz - 1]; ++i) ans = max(ans, f[1][i]);
  return tot - ans;
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", &x[i].a), p[i] = x[i].a;
  for (i = 1; i <= n; ++i) scanf("%d", &x[i].b);
  sort(p + 1, p + n + 1);
  sz = unique(p + 1, p + n + 1) - p - 1;
  for (i = 1; i <= n; ++i)
    cnt[x[i].rnk = lower_bound(p + 1, p + sz + 1, x[i].a) - p]++;
  for (i = 1; i <= sz; ++i) pre[i] = pre[i - 1] + cnt[i];
  if (sz == 1) {
    long long aa = 0, bb = 0;
    for (i = 1; i <= n; ++i) aa += 1ll * x[i].a, bb += 1ll * x[i].b;
    double qwq = (double)aa / bb * 1000.0;
    printf("%I64d", (long long)ceil(qwq));
    return 0;
  }
  double l = 0, r = 1e8;
  while (r - l > eps) {
    double mid = (r - l) * 0.5 + l;
    if (check(mid) <= 0)
      r = mid;
    else
      l = mid;
  }
  l *= 1000.0;
  printf("%I64d", (long long)ceil(l));
}
