#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int inf = 0x7fffffff;
const int N = 55;
double X, f[N][N][N];
bool vis[N][N][N];
int n;
long long ans;
struct node {
  double a, c;
};
node t[N];
bool cmp(node x, node y) { return x.a > y.a; }
double dfs(int i, int j, int k) {
  if (i >= n) return 0;
  if (vis[i][j][k]) return f[i][j][k];
  vis[i][j][k] = 1;
  double mn = inf;
  if (i < n - 1 && t[i].a == t[i + 1].a) {
    if (j) mn = min(mn, dfs(i + 1, j - 1, k));
    mn = min(mn, dfs(i + 1, j, k + 1) + t[i].a - X * t[i].c);
  } else if (t[i].a != t[i + 1].a || i == n - 1) {
    if (j) mn = min(mn, dfs(i + 1, j + k - 1, 0));
    mn = min(mn, dfs(i + 1, j + k + 1, 0) + t[i].a - X * t[i].c);
  }
  return f[i][j][k] = mn;
}
bool judge(double k) {
  X = k;
  memset(vis, 0, sizeof(vis));
  memset(f, 0, sizeof(f));
  return dfs(0, 0, 0) <= 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i].a;
  }
  for (int i = 0; i < n; i++) {
    cin >> t[i].c;
  }
  sort(t, t + n, cmp);
  double l = 0.0, r = 1e8;
  for (int T = 1; T < 100; T++) {
    double mid = (r + l) / 2.0;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  ans = (ceil)(l * 1000);
  cout << ans << endl;
}
