#include <bits/stdc++.h>
const int md = 1e9 + 7, inf = 1e9 + 7;
const long long hs = 199;
const long double eps = 1e-5, pi = acos(-1);
using namespace std;
bool cmp(pair<long long, long long> &aa, pair<long long, long long> &bb) {
  if (aa.first != bb.first) return aa.first > bb.first;
  return aa.second > bb.second;
}
bool cmp2(pair<long double, int> &aa, pair<long double, int> &bb) {
  if (aa.first != bb.first) return aa.first < bb.first;
  return aa.second < bb.second;
}
long long n;
vector<pair<long long, long long>> a;
vector<pair<long double, int>> b;
vector<bool> took;
bool checktook() {
  int p1 = 0, p2 = 0;
  while (p2 < n) {
    while (p2 < n && took[p2]) p2++;
    if (p2 == n) return true;
    while (p1 < p2 && !took[p1]) p1++;
    if (p1 == p2) return false;
    if (a[p1].first <= a[p2].first) return false;
    p1++;
    p2++;
  }
  return true;
}
bool can(long double P) {
  for (int i = 0; i < n; i++)
    b[i].first = a[i].first - P * a[i].second, b[i].second = i;
  for (int i = 0; i < n; i++) took[i] = false;
  sort(b.begin(), b.end(), cmp2);
  long double sum = 0;
  int nxt = 0;
  while (!checktook()) {
    sum += b[nxt].first;
    took[b[nxt].second] = true;
    nxt++;
  }
  if (sum <= 0) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  a.resize(n);
  took.resize(n);
  b.resize(n);
  for (auto &i : a) cin >> i.first;
  for (auto &i : a) cin >> i.second;
  sort(a.begin(), a.end(), cmp);
  long double lo = 0, hi = 1e8 + 5, mid;
  while (abs(hi - lo) > eps) {
    mid = (lo + hi) / 2;
    if (can(mid))
      hi = mid;
    else
      lo = mid;
  }
  cout << ceil(1000 * lo) << '\n';
}
