#include <bits/stdc++.h>
using namespace std;
const int N = 52;
int n;
pair<int, int> a[N];
double b[N];
double dp[N][N][N];
bool v[N][N][N];
double solve(int i, int j, int k) {
  if (i == n + 1) return 0;
  if (v[i][j][k]) return dp[i][j][k];
  v[i][j][k] = true;
  double &ret = dp[i][j][k];
  ret = b[i] + solve(i + 1, a[i - 1].first > a[i].first ? j + k : j,
                     a[i - 1].first > a[i].first ? 1 : k + 1);
  if (j)
    ret = min(ret, solve(i + 1, a[i - 1].first > a[i].first ? j + k - 1 : j - 1,
                         a[i - 1].first > a[i].first ? 0 : k));
  if (k and a[i - 1].first > a[i].first)
    ret = min(ret, solve(i + 1, j + k - 1, 0));
  return ret;
}
bool check(double mid) {
  for (int i = 1; i <= n; ++i) b[i] = a[i].first - mid * a[i].second;
  memset(v, 0, sizeof v);
  return solve(1, 0, 0) < 1e-12;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].first);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i].second);
  sort(a + 1, a + 1 + n, greater<pair<int, int> >());
  double l = 0, r = 1000000000;
  for (int i = 0; i <= 99; ++i) {
    double mid = (l + r) / 2;
    if (check(mid))
      r = mid;
    else
      l = mid;
  }
  printf("%I64d", (long long)ceil(1000 * l));
}
