#include <bits/stdc++.h>
using namespace std;
const double w = 100000010;
const int N = 55;
int n, m, i, j, t;
int a[N], b[N];
double l, r, mid, p, f[N][N][N];
bool bz[N][N][N];
long long ans;
double min(double a, double b) {
  if (a < b)
    return a;
  else
    return b;
}
void qsort(int l, int r) {
  int i = l, j = r, mid = a[(l + r) >> 1];
  while (i <= j) {
    while (a[i] > mid) i++;
    while (a[j] < mid) j--;
    if (i <= j) {
      swap(a[i], a[j]), swap(b[i], b[j]);
      i++, j--;
    }
  }
  if (l < j) qsort(l, j);
  if (i < r) qsort(i, r);
}
double dg(int i, int j, int k) {
  if (i > n) return 0;
  if (bz[i][j][k]) return f[i][j][k];
  bz[i][j][k] = 1;
  double q = w, t = a[i] - mid * b[i];
  if (i < n && a[i] == a[i + 1]) {
    if (j) q = min(q, dg(i + 1, j - 1, k));
    q = min(q, dg(i + 1, j, k + 1) + t);
  } else {
    if (j) q = min(q, dg(i + 1, j + k - 1, 0));
    q = min(q, dg(i + 1, j + k + 1, 0) + t);
  }
  f[i][j][k] = q;
  return q;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  qsort(1, n);
  l = 0, r = 100000000;
  while (l < r) {
    t++;
    if (t > 100) break;
    mid = (l + r) / 2;
    memset(bz, 0, sizeof(bz));
    if (dg(1, 0, 0) <= 0)
      r = mid;
    else
      l = mid;
  }
  ans = ceil(l * 1000);
  printf("%I64d", ans);
}
