#include <bits/stdc++.h>
using namespace std;
const long long INf = 1152921504606846976;
struct node {
  long long u, v;
} a[70];
long long n;
bool cmp(node p, node q) { return p.u > q.u; }
long long f[70][70][70];
bool judge(long long xx) {
  memset(f, 0x7f, sizeof(f));
  f[1][0][0] = 0;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 0; j <= i; ++j) {
      for (long long k = 0; k <= i - j; ++k) {
        if (a[i + 1].u != a[i].u) {
          if (j != 0)
            f[i + 1][j + k - 1][0] = min(f[i + 1][j + k - 1][0], f[i][j][k]);
          f[i + 1][j + k + 1][0] =
              min(f[i + 1][j + k + 1][0], f[i][j][k] + a[i].u - a[i].v * xx);
        } else {
          if (j != 0) f[i + 1][j - 1][k] = min(f[i + 1][j - 1][k], f[i][j][k]);
          f[i + 1][j][k + 1] =
              min(f[i + 1][j][k + 1], f[i][j][k] + a[i].u - a[i].v * xx);
        }
      }
    }
  }
  for (long long i = 0; i <= n + 1; ++i) {
    for (long long j = 0; j <= n + 1; ++j) {
      if (f[n + 1][i][j] <= 0) return true;
    }
  }
  return false;
}
int main(int argc, char const *argv[]) {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; ++i) {
    scanf("%I64d", &a[i].u);
    a[i].u *= 1000;
  }
  for (long long i = 1; i <= n; ++i) scanf("%I64d", &a[i].v);
  sort(a + 1, a + n + 1, cmp);
  long long l = 0, r = INf, ans, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (judge(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%I64d\n", ans);
  return 0;
}
