#include <bits/stdc++.h>
using namespace std;
const int N = 150000 + 10;
const double eps = 1e-9;
int rd() {
  int x = 0, w = 1;
  char ch = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * w;
}
struct sd {
  double x;
  int i;
  bool operator<(const sd &bb) const { return x < bb.x; }
};
priority_queue<sd> hp;
struct node {
  int a, b;
  bool operator<(const node &bb) const {
    return 1ll * a * bb.b != 1ll * b * bb.a ? 1ll * a * bb.b > 1ll * b * bb.a
                                            : a > bb.a;
  }
} a[N];
int n, m, t, sq[N], blg[N], blk[N][2], pz[N];
bool cmp(int na, int nb) { return a[na].a > a[nb].a; }
double pr[N];
int main() {
  n = rd();
  for (int i = 1; i <= n; ++i) a[i].a = rd();
  for (int i = 1; i <= n; ++i) a[i].b = rd();
  sort(a + 1, a + n + 1);
  for (int i = 1, j = 1; i <= n; ++j, i = j) {
    ++t;
    while (j < n && 1ll * a[i].a * a[j + 1].b == 1ll * a[j + 1].a * a[i].b) ++j;
    blk[t][0] = i, blk[t][1] = j;
    for (int k = i; k <= j; ++k) blg[k] = t;
  }
  for (int i = 1; i <= n; ++i) pr[i] = pr[i - 1] + a[i].b;
  for (int i = 1; i <= n; ++i) sq[i] = i;
  sort(sq + 1, sq + n + 1, cmp);
  double l = 0, r = 1, an = 0;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    while (!hp.empty()) hp.pop();
    for (int i = 1; i <= t; ++i) {
      pz[i] = blk[i][0];
      hp.push((sd){(double)a[pz[i]].a *
                       (1.0 - mid * (pr[blk[i][0] - 1] + a[pz[i]].b) / pr[n]),
                   pz[i]});
    }
    bool ok = 1;
    for (int i = 1, j = 1; ok && i <= n; ++j, i = j) {
      while (j < n && a[sq[j + 1]].a == a[sq[i]].a) ++j;
      for (int k = i; k <= j; ++k) {
        int x = sq[k], xx = blg[x];
        while (pz[xx] <= blk[xx][1] && a[x].a == a[pz[xx]].a) ++pz[xx];
        if (pz[xx] <= blk[xx][1])
          hp.push(
              (sd){(double)a[pz[xx]].a *
                       (1.0 - mid * (pr[blk[xx][0] - 1] + a[pz[xx]].b) / pr[n]),
                   pz[xx]});
      }
      while (!hp.empty() && hp.top().i < pz[blg[hp.top().i]]) hp.pop();
      if (hp.empty()) break;
      for (int k = i; k <= j; ++k) {
        int x = sq[k], xx = blg[x];
        ok &= hp.top().x <
              (double)a[x].a * (1.0 - mid * pr[blk[xx][1]] / pr[n]) + eps;
      }
    }
    if (ok)
      an = mid, l = mid + eps;
    else
      r = mid - eps;
  }
  printf("%.8lf\n", an);
  return 0;
}
