#include <bits/stdc++.h>
using namespace std;
const int N = 53;
int n;
pair<int, int> a[N];
double dp[N][N][N];
bool vis[N][N][N];
double solve(int i, int j, int k, double thr) {
  if (i == n + 1) return 0;
  double &ret = dp[i][j][k];
  if (vis[i][j][k]) return ret;
  vis[i][j][k] = true;
  ret = a[i].second * thr - a[i].first +
        solve(i + 1, a[i].first < a[i - 1].first ? j + k : j,
              a[i].first < a[i - 1].first ? 1 : k + 1, thr);
  if (j)
    ret = max(ret, solve(i + 1, a[i].first < a[i - 1].first ? j + k - 1 : j - 1,
                         a[i].first < a[i - 1].first ? 0 : k, thr));
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int(i) = (1); (i) <= (int)(n); (i)++) scanf("%d", &a[i].first);
  for (int(i) = (1); (i) <= (int)(n); (i)++) scanf("%d", &a[i].second);
  sort(a + 1, a + n + 1, greater<pair<int, int> >());
  double l = 0, r = 1000000007;
  while (fabs(r - l) > 1e-9) {
    double mid = (l + r) / 2;
    memset(vis, false, sizeof vis);
    double res = solve(1, 0, 0, mid);
    if (solve(1, 0, 0, mid) > -1e-9)
      r = mid;
    else
      l = mid;
  }
  printf("%lld\n", long long(ceil(1000 * l)));
  return 0;
}
