#include <bits/stdc++.h>
using namespace std;
int n;
long long a[70], b[70], f[70][70];
struct info {
  long long x, y;
} c[70];
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
bool cmp(info a, info b) {
  if (a.x != b.x)
    return a.x > b.x;
  else
    return a.y > b.y;
}
bool ok(long long x) {
  for (int i = 1; i <= n; ++i) c[i].x = a[i], c[i].y = a[i] - x * b[i];
  sort(c + 1, c + 1 + n, cmp);
  for (int i = 2; i <= n; ++i) c[i].y += c[i - 1].y;
  int L = 1, R = 1, cnt = 0;
  f[0][0] = 0;
  while (L <= n) {
    ++cnt;
    R = L;
    while (R < n && c[R].x == c[R + 1].x) ++R;
    for (int i = 0; i < L; ++i) {
      if (f[cnt - 1][i] == 1ll * 0x3f3f3f3f * 0x3f3f3f3f) continue;
      for (int j = L - 1; j <= R; ++j)
        if (j - L + 1 <= i)
          chkmin(f[cnt][i - (j - L + 1) + R - j],
                 f[cnt - 1][i] + c[R].y - c[j].y);
    }
    L = R + 1;
  }
  int ret = 0;
  for (int i = 0; i <= n; ++i)
    if (f[cnt][i] <= 0) ret = 1;
  for (int i = 0; i <= cnt; ++i)
    for (int j = 0; j <= n; ++j) f[i][j] = 1ll * 0x3f3f3f3f * 0x3f3f3f3f;
  return ret;
}
int main() {
  read(n);
  long long l = 0, r = 0;
  for (int i = 1; i <= n; ++i) read(a[i]), a[i] = a[i] * 1000ll, r += a[i];
  for (int i = 1; i <= n; ++i) read(b[i]);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j) f[i][j] = 1ll * 0x3f3f3f3f * 0x3f3f3f3f;
  while (l + 1 < r) {
    long long mid = (l + r) / 2;
    if (ok(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d\n", r);
  return 0;
}
