#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > a;
double dp[51][51][51];
bool vis[51][51][51];
double solve(double x[], int i, int j, int k) {
  if (j < 0) return 1e12;
  if (i == n) return 0;
  if (vis[i][j][k]) return dp[i][j][k];
  double ret =
      x[i] + solve(x, i + 1,
                   (i != 0 && a[i - 1].first == a[i].first) ? j : j + k,
                   (i != 0 && a[i - 1].first == a[i].first) ? k + 1 : 1);
  dp[i][j][k] = ret = min(
      ret, solve(x, i + 1,
                 (i != 0 && a[i - 1].first == a[i].first) ? j - 1 : j + k - 1,
                 (i != 0 && a[i - 1].first == a[i].first) ? k : 0));
  vis[i][j][k] = true;
  return ret;
}
bool check(double m) {
  double x[n];
  for (int i = 0; i < n; i++) {
    x[i] = a[i].first - m * a[i].second;
  }
  memset(dp, 0, sizeof dp);
  memset(vis, 0, sizeof vis);
  return solve(x, 0, 0, 0) <= 1e-12;
}
int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i].first;
  for (int i = 0; i < n; i++) cin >> a[i].second;
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  double l = 0, r = 1e9;
  for (int i = 0; i < 100; i++) {
    double mid = l + (r - l) / 2;
    if (check(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << ceil(r * 1000) << endl;
}
