#include <bits/stdc++.h>
using namespace std;
template <typename _tp>
inline void cmax(_tp& x, const _tp y) {
  if (x < y) x = y;
}
template <typename _tp>
inline void read(_tp& x) {
  char ch = getchar(), sgn = 0;
  x = 0;
  while (ch != '-' and !isdigit(ch)) ch = getchar();
  if (ch == '-') ch = getchar(), sgn = 1;
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  if (sgn) x = -x;
}
const int N = 150001;
long long sm[N], T;
int n;
struct node {
  int p, t;
  long long mi, mx;
} a[N];
inline bool cmp_r(const node& A, const node& B) {
  return (long long)A.p * B.t > (long long)A.t * B.p;
}
inline bool cmp_p(const node& A, const node& B) { return A.p < B.p; }
inline double calc(const int& _p, const long long& _t, const double& _c) {
  return _p * (1 - _c * _t / T);
}
bool para(const double& c) {
  double mini = 0;
  for (int l = 1, r = 1; l <= n; l = r) {
    while (r <= n and a[l].p == a[r].p) ++r;
    for (int i = l; i < r; ++i)
      if (calc(a[i].p, a[i].mx, c) < mini) return true;
    for (int i = l; i < r; ++i) cmax(mini, calc(a[i].p, a[i].mi, c));
  }
  return false;
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(a[i].p);
  for (int i = 1; i <= n; ++i) read(a[i].t), T += a[i].t;
  sort(a + 1, a + n + 1, cmp_r);
  for (int i = 1; i <= n; ++i) sm[i] = sm[i - 1] + a[i].t;
  for (int l = 1, r = 1; l <= n; l = r) {
    while (r <= n and (long long) a[l].p * a[r].t == (long long)a[l].t * a[r].p)
      ++r;
    for (int i = l; i < r; ++i)
      a[i].mi = sm[l - 1] + a[i].t, a[i].mx = sm[r - 1];
  }
  sort(a + 1, a + n + 1, cmp_p);
  const double eps = 5e-7;
  double l = 0., r = 1., c;
  while (l + eps < r) {
    c = 0.5 * (l + r);
    if (para(c))
      r = c;
    else
      l = c;
  }
  printf("%.10lf\n", l);
  return 0;
}
