#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vp;
double T = 0;
bool check(double c) {
  vector<pair<int, pair<double, double>>> e;
  double total = 0;
  int n = vp.size();
  for (int i = 0, j = 0; i < n;) {
    while (j < n && vp[i].first * 1ll * vp[j].second ==
                        vp[i].second * 1ll * vp[j].first) {
      j++;
    }
    double ctotal = total;
    for (int k = i; k < j; k++) ctotal += vp[k].second;
    for (int k = i; k < j; k++) {
      double minscore = (double)vp[k].first * (1.0 - c * ctotal / T);
      double maxscore =
          (double)vp[k].first * (1.0 - c * (total + (double)vp[k].second) / T);
      e.push_back(make_pair(vp[k].first, make_pair(maxscore, minscore)));
    }
    total = ctotal;
    i = j;
  }
  sort(e.begin(), e.end());
  double pmax = -1e9;
  int lst = -1;
  for (auto &x : e) {
    if (lst != x.first && pmax > x.second.second) return false;
    if (pmax < x.second.first) {
      pmax = x.second.first;
      lst = x.first;
    }
  }
  return true;
}
signed main() {
  int n;
  cin >> n;
  vp.resize(n);
  for (int i = 0; i < n; i++) cin >> vp[i].first;
  for (int i = 0; i < n; i++) cin >> vp[i].second;
  for (int i = 0; i < n; i++) T += vp[i].second;
  sort(vp.begin(), vp.end(), [&](pair<int, int> a, pair<int, int> b) {
    return (1ll * a.first * b.second > 1ll * a.second * b.first);
  });
  double L = 0, R = 1;
  for (int i = 0; i < 60; i++) {
    double mid = (L + R) / 2.0;
    if (check(mid))
      L = mid;
    else
      R = mid;
  }
  cout << fixed << setprecision(10) << L << endl;
}
