#include <bits/stdc++.h>
const int N = 55;
using namespace std;
int n;
pair<long long, long long> p[N], b[N];
long long f[N][N], w[N];
template <typename T>
inline T read() {
  T x = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * w;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first == b.first ? a.second > b.second : a.first > b.first;
}
bool check(long long mid) {
  for (int i = 1; i <= n; i++)
    b[i].first = p[i].first, b[i].second = p[i].first - mid * p[i].second;
  sort(b + 1, b + n + 1, cmp);
  long long res = 0;
  for (int i = 1; i <= n; i++) res += b[i].second;
  memset(f, -0x3f, sizeof(f)), f[0][0] = 0;
  for (int j = 1, i = 1; i <= n; i = j) {
    while (j <= n && b[j].first == b[i].first) j++;
    w[0] = 0;
    for (int k = 1; k <= j - i; k++) w[k] = w[k - 1] + b[i + k - 1].second;
    for (int k = 0; k <= i - 1; k++)
      for (int y = 0; y <= min(j - i, i - 1 - 2 * k); y++)
        f[j - 1][k + y] = max(f[j - 1][k + y], f[i - 1][k] + w[y]);
  }
  for (int i = 0; i <= n; i++)
    if (res - f[n][i] <= 0) return 1;
  return 0;
}
int main() {
  n = read<int>();
  for (int i = 1; i <= n; i++) p[i].first = read<long long>() * 1000;
  for (int i = 1; i <= n; i++) p[i].second = read<long long>();
  long long l = 1, r = 1000000000000, mid, ans = r;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (check(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
