#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ld = long double;
mt19937 rnd(time(nullptr));
const double inf = -1e9;
bool Check(vector<pair<lli, lli>>& data, double w) {
  lli n = data.size();
  vector<vector<vector<double>>> dp(
      n, vector<vector<double>>(n + 1, vector<double>(n + 1, inf)));
  dp[0][0][1] = (w * data[0].second - data[0].first);
  for (lli i = 0; i < n - 1; i++) {
    for (lli j = 0; j < n + 1; j++) {
      for (lli k = 0; k < n + 1; k++) {
        if (dp[i][j][k] == inf) continue;
        if (data[i + 1].first == data[i].first) {
          if (k + 1 < n + 1)
            dp[i + 1][j][k + 1] =
                max(dp[i + 1][j][k + 1],
                    dp[i][j][k] + (w * data[i + 1].second - data[i + 1].first));
          if (j - 1 >= 0)
            dp[i + 1][j - 1][k] = max(dp[i + 1][j - 1][k], dp[i][j][k]);
        } else {
          if (j + k < n + 1)
            dp[i + 1][j + k][1] =
                max(dp[i + 1][j + k][1],
                    dp[i][j][k] + (w * data[i + 1].second - data[i + 1].first));
          if ((j + k - 1 >= 0) && (j + k - 1 < n + 1))
            dp[i + 1][j + k - 1][0] = max(dp[i + 1][j + k - 1][0], dp[i][j][k]);
        }
      }
    }
  }
  double result = dp[n - 1][0][0];
  for (lli j = 0; j < n + 1; j++)
    for (lli k = 0; k < n + 1; k++) result = max(result, dp[n - 1][j][k]);
  return (result >= 0);
}
void BinarySearch(vector<pair<lli, lli>>& data) {
  double left = -1, right = 1e10;
  for (lli k = 0; k < 200; k++) {
    double middle = (left + right) / 2;
    if (Check(data, middle))
      right = middle;
    else
      left = middle;
  }
  cout << fixed << setprecision(0) << ceil(1000 * left);
}
inline void Solve() {
  lli n = 0;
  cin >> n;
  vector<pair<lli, lli>> data(n);
  for (auto& it : data) cin >> it.first;
  for (auto& it : data) cin >> it.second;
  sort(data.begin(), data.end(),
       [](const pair<lli, lli>& a, const pair<lli, lli>& b) {
         return a.first > b.first;
       });
  BinarySearch(data);
}
signed main() {
  Solve();
  return 0;
}
