#include <bits/stdc++.h>
const double EPS = 1e-4;
int n;
struct data {
  double a, b, c;
} d[510];
double f[510][510], sa, sb, tmp[510];
inline bool check(double mid) {
  for (int i = 1; i <= n; i++) d[i].c = d[i].a - d[i].b * mid;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) f[i][j] = 1e100;
  f[0][0] = 0;
  int all = 0, cnt = 0;
  for (int i = 1; i <= n; i++) {
    tmp[++all] = d[i].c;
    if (d[i].a != d[i + 1].a) {
      ++cnt;
      std::sort(tmp + 1, tmp + all + 1);
      for (int i = 1; i <= all; i++) tmp[i] += tmp[i - 1];
      for (int j = 0; j <= all; j++) {
        for (int k = all - j; k <= i; k++) {
          f[cnt][k - (all - j) + j] =
              std::min(f[cnt][k - (all - j) + j], f[cnt - 1][k] + tmp[j]);
        }
      }
      all = 0;
    }
  }
  double res = 1e100;
  for (int i = 0; i <= n; i++) res = std::min(res, f[cnt][i]);
  return res <= 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lf", &d[i].a), sa += d[i].a;
  for (int i = 1; i <= n; i++) scanf("%lf", &d[i].b), sb += d[i].b;
  std::sort(d + 1, d + n + 1,
            [](const data& a, const data& b) { return a.a > b.a; });
  double l = 0, r = sa / sb;
  while (r - l > EPS) {
    double mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%.0lf\n", round((l + r) / 2 * 1000));
}
