#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<long long, int>> a(n);
  for (int i = 0; i < n; i++) cin >> a[i].first;
  for (int i = 0; i < n; i++) cin >> a[i].second;
  for (int i = 0; i < n; i++) a[i].first *= 1000;
  sort(a.begin(), a.end(),
       [&](pair<long long, int> &p0, pair<long long, int> &p1) {
         if (p0.first == p1.first) {
           return p0.second < p1.second;
         }
         return p0.first > p1.first;
       });
  vector<vector<pair<long long, int>>> ta;
  int m = 0;
  for (int i = 0; i < n; i++) {
    int j = i;
    ta.push_back(vector<pair<long long, int>>());
    while (j < n && a[j].first == a[i].first) {
      ta[m].push_back(a[j]);
      j++;
    }
    i = j - 1;
    m++;
  }
  long long left = 0, right = 1LL << 50;
  while (left < right) {
    long long mid = (left + right) / 2;
    vector<vector<long long>> dp(m + 1, vector<long long>(n + 1, -(1LL << 56)));
    dp[0][0] = 0;
    for (int i = 0; i < m; i++) {
      int g = ta[i].size();
      long long sum0 = 0, sum1 = 0;
      for (int j = 0; j < g; j++) {
        sum1 += ta[i][j].second * mid - ta[i][j].first;
      }
      for (int j = 0; j <= g; j++) {
        for (int k = 0; k <= n; k++) {
          if ((k + g - j - j) < 0 || (k + g - j - j) > n) continue;
          if (k < j) continue;
          dp[i + 1][k + g - j - j] =
              max(dp[i + 1][k + g - j - j], dp[i][k] + sum1 - sum0);
        }
        if (j < g) {
          sum0 += ta[i][j].second * mid - ta[i][j].first;
        }
      }
    }
    bool bo = false;
    for (int i = 0; i <= n; i++) {
      if (dp[m][i] >= 0) bo = true;
    }
    if (bo) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }
  cout << left << "\n";
  return 0;
}
