#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000009LL;
long long large = 2000000000000000000LL;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n, 0);
  vector<long long> b(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] *= 1000;
  }
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<long long> uni = a;
  sort(uni.begin(), uni.end());
  uni.erase(unique(uni.begin(), uni.end()), uni.end());
  int sz = (int)uni.size();
  map<int, int> comp;
  for (int i = 0; i < sz; i++) comp[uni[i]] = i;
  vector<vector<int> > adj(sz, vector<int>());
  for (int i = 0; i < n; i++) adj[comp[a[i]]].push_back(i);
  long long low = 1;
  long long high = 1000000000000LL;
  long long ans = high;
  while (low <= high) {
    long long mid = (low + high) / 2;
    vector<long long> dp(60, large);
    dp[0] = 0;
    for (int i = sz - 1; i >= 0; i--) {
      vector<pair<long long, int> > e;
      for (int j = 0; j < (int)adj[i].size(); j++) {
        int id = adj[i][j];
        e.push_back(pair<long long, int>(a[id] - mid * b[id], id));
      }
      sort(e.begin(), e.end());
      reverse(e.begin(), e.end());
      vector<long long> suf;
      for (int j = 0; j < (int)e.size(); j++) suf.push_back(e[j].first);
      suf.push_back(0);
      for (int j = (int)suf.size() - 2; j >= 0; j--) suf[j] += suf[j + 1];
      vector<long long> dp1(60, large);
      for (int i = 0; i <= 50; i++) {
        for (int j = 0; j < (int)suf.size(); j++) {
          if (i >= j) {
            int re = (int)e.size() - j;
            if (i - j + re <= 50)
              dp1[i - j + re] = min(dp1[i - j + re], dp[i] + suf[j]);
          }
        }
      }
      dp = dp1;
    }
    long long mini = large;
    for (int i = 0; i <= 50; i++) mini = min(mini, dp[i]);
    if (mini <= 0) {
      ans = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
