#include <bits/stdc++.h>
using namespace std;
long long n;
vector<pair<long long, long long>> a;
bool func(long double val) {
  vector<vector<long double>> dp(n + 2, vector<long double>(n + 2, 1e12));
  auto prev = dp;
  queue<pair<long long, long long>> q;
  prev[0][1] = a[0].first - val * a[0].second;
  q.push({0, 1});
  for (long long k = 1; k < n; ++k) {
    queue<pair<long long, long long>> nextQ;
    while (!q.empty()) {
      long long i = q.front().first, j = q.front().second;
      q.pop();
      long double z = prev[i][j] + a[k].first - val * a[k].second;
      if (a[k].first == a[k - 1].first) {
        if (dp[i][j + 1] > z) {
          dp[i][j + 1] = z;
          nextQ.push({i, j + 1});
        }
        if (i > 0 && dp[i - 1][j] > prev[i][j]) {
          dp[i - 1][j] = prev[i][j];
          nextQ.push({i - 1, j});
        }
      } else {
        if (dp[i + j][1] > z) {
          dp[i + j][1] = z;
          nextQ.push({i + j, 1});
        }
        if (i + j > 0 && dp[i + j - 1][0] > prev[i][j]) {
          dp[i + j - 1][0] = prev[i][j];
          nextQ.push({i + j - 1, 0});
        }
      }
    }
    q = nextQ;
    prev = dp;
    dp = vector<vector<long double>>(n + 2, vector<long double>(n + 2, 1e12));
  }
  bool res = false;
  for (long long i = 0; i < n + 2; ++i) {
    for (long long j = 0; j < n + 2; ++j) {
      res = res || prev[i][j] <= 0;
    }
  }
  return res;
}
void Solve() {
  cin >> n;
  a = vector<pair<long long, long long>>(n);
  for (long long i = 0; i < (n); ++i) cin >> a[i].first;
  for (long long i = 0; i < (n); ++i) cin >> a[i].second;
  sort(a.rbegin(), a.rend());
  long double l = 0, r = 1e10;
  for (long long i = 0; i < (250); ++i) {
    long double mid = (l + r) / 2;
    if (!func(mid))
      l = mid;
    else
      r = mid;
  }
  cout << (long long)ceil(l * 1000);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  Solve();
  return 0;
}
