#include <bits/stdc++.h>
using namespace std;
const double INF = 1e18, eps = 1e-6;
const int base = 50 + 5, maxn = 50 + 5;
bool vis[maxn][maxn][maxn];
double mem[maxn][maxn][maxn], gusse;
pair<int, int> a[maxn];
int n;
double dp(int cur, int task, int same) {
  if (cur == n) return 0;
  double ans = INF;
  if (vis[cur][task][same]) return mem[cur][task][same];
  vis[cur][task][same] = 1;
  if (cur < n - 1 && a[cur].first == a[cur + 1].first) {
    if (task > 0) ans = min(ans, dp(cur + 1, task - 1, same));
    ans = min(ans, dp(cur + 1, task, same + 1) + a[cur].first -
                       a[cur].second * gusse);
  } else {
    if (task > 0) ans = min(ans, dp(cur + 1, task + same - 1, 0));
    ans = min(ans, dp(cur + 1, task + same + 1, 0) + a[cur].first -
                       a[cur].second * gusse);
  }
  return mem[cur][task][same] = ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].second);
  }
  sort(a, a + n, greater<pair<int, int> >());
  double l = 0, r = 1e10;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    gusse = mid;
    memset(vis, 0, sizeof vis);
    if (dp(0, 0, 0) < 0)
      r = mid;
    else
      l = mid;
  }
  printf("%lld\n", (long long)(ceil(l * 1000)));
  return 0;
}
