#include <bits/stdc++.h>
using namespace std;
long long inf;
int n;
long long f[65][65], sum[65];
struct tt {
  long long a, b;
  bool operator<(const tt &x) const { return a == x.a ? b > x.b : a > x.a; }
} p[65];
bool judge(long long mid) {
  memset(f, 127, sizeof(f));
  inf = f[0][0];
  f[0][0] = 0;
  for (int i = 1, loc; i <= n; i = loc + 1) {
    for (loc = i; p[loc + 1].a == p[i].a; loc++)
      ;
    sum[i - 1] = 0;
    for (int j = i; j <= loc; j++) sum[j] = sum[j - 1] + p[j].b;
    for (int j = 0; j <= n; j++)
      if (f[i - 1][j] != inf) {
        for (int k = max(0, (loc - i + 1) - (2 * j - (i - 1)));
             k <= min(n - j, loc - i + 1); k++) {
          f[loc][j + k] =
              min(f[loc][j + k], f[i - 1][j] + p[i].a * k -
                                     mid * (sum[i + k - 1] - sum[i - 1]));
        }
      }
  }
  for (int i = 0; i <= n; i++)
    if (f[n][i] <= 0) return true;
  return false;
}
void work() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &p[i].a), p[i].a *= 1000;
  for (int i = 1; i <= n; i++) scanf("%I64d", &p[i].b);
  sort(p + 1, p + n + 1);
  long long l = 1, r = 1ll * 100000000 * 1000, ans;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (judge(mid))
      r = mid - 1, ans = mid;
    else
      l = mid + 1;
  }
  printf("%I64d\n", ans);
}
int main() {
  work();
  return 0;
}
