#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return {i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ll = long long;
constexpr int mod = 1000 * 1000 * 1000 + 7;
void DodajDo(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int Dodaj(int a, int b) {
  DodajDo(a, b);
  return a;
}
int Mnoz(int a, int b) { return (ll)a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
constexpr int nax = 55;
int n;
int a[nax];
int b[nax];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  ll p = 1, k = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    k += a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  k *= 1000;
  auto Ok = [&](ll x) -> bool {
    vector<pair<ll, int>> kto;
    set<int> niemam;
    multiset<int> mam;
    for (int i = 0; i < n; i++) {
      kto.emplace_back(a[i] * 1000 - x * b[i], i);
      niemam.insert(i);
    }
    sort(kto.begin(), kto.end());
    ll suma = 0;
    for (auto& it : kto) {
      if (suma + it.first > 0) break;
      suma += it.first;
      assert(suma <= 0);
      niemam.erase(it.second);
      mam.insert(a[it.second]);
    }
    debug() << " ["
               "niemam"
               ": "
            << (niemam)
            << "] "
               " ["
               "mam"
               ": "
            << (mam) << "] ";
    for (int y : niemam) {
      auto it = mam.upper_bound(a[y]);
      if (it == mam.end()) {
        return false;
      }
      mam.erase(it);
    }
    return true;
  };
  while (p < k) {
    const ll x = (p + k) / 2;
    const bool ok = Ok(x);
    if (ok) {
      k = x;
    } else {
      p = x + 1;
    }
  }
  cout << k << endl;
  return 0;
}
