#include <bits/stdc++.h>
using namespace std;
const long long N = 70;
struct A {
  long long x, y;
} a[N];
long long n, m;
long long f[N][N][N];
bool cmp(A x, A y) { return x.x > y.x; }
long long gt(A x) {
  if (x.x == 0) return (1 << 30);
  return (double(x.x) / double(x.y));
}
bool dp(long long ans) {
  memset(f, 127, 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].x != a[i].x) {
          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].x - a[i].y * ans);
        }
        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].x - a[i].y * ans);
      }
    }
  }
  long long x = 1125899906842624;
  for (long long i = 0; i <= n + 1; i++)
    for (long long j = 0; j <= n + 1; j++) x = min(x, f[n + 1][i][j]);
  return (x <= 0);
}
int main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; i++) scanf("%I64d", &a[i].x), a[i].x *= 1000;
  for (long long i = 1; i <= n; i++) scanf("%I64d", &a[i].y);
  sort(a + 1, a + n + 1, cmp);
  long long ans = 0;
  long long l = 0, r = 1125899906842624, mid;
  while (r >= l) {
    mid = (l + r) / 2;
    if (dp(mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  printf("%I64d", ans);
  return 0;
}
