#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
inline void print(long long x) {
  if (x < 0) putchar('-'), x = ~x + 1;
  if (x >= 10) print(x / 10);
  putchar((x % 10) | 48);
}
long long n;
pair<long long, long long> a[100];
long long f[110][110];
long long siz[110];
vector<pair<long long, long long> > vec[110];
long long m;
bool check(long long x) {
  long long c = 0;
  memset(f, 0x3f, sizeof(f));
  f[0][0] = 0;
  long long res = 100;
  for (long long i = 1; i <= m; ++i) {
    c += siz[i];
    for (long long j = 0; j <= c; ++j) {
      long long s = 0;
      for (long long k = 0; k <= siz[i] && j - k >= c - j; ++k) {
        if (k) s += vec[i][k - 1].first - x * vec[i][k - 1].second;
        f[i][j] = min(f[i][j], f[i - 1][j - k] + s);
        if (i == m) res = min(res, f[i][j]);
      }
    }
  }
  return res <= 0;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; ++i) a[i].first = 1000 * read();
  for (long long i = 1; i <= n; ++i) a[i].second = read();
  sort(a + 1, a + n + 1);
  reverse(a + 1, a + n + 1);
  for (long long i = 1; i <= n; ++i) {
    if (a[i].first != a[i - 1].first) ++m;
    vec[m].push_back(a[i]);
    ++siz[m];
  }
  long long l = 0, r = 1e11, res = -1;
  while (l <= r) {
    long long mid = l + r >> 1;
    if (check(mid))
      res = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  print(res);
}
