#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-8;
int n;
long long s[N];
double l, r = 1;
struct node {
  long long a, t, l, r;
} a[N];
bool cmp(node a, node b) { return a.a * b.t > b.a * a.t; }
bool cmp2(node a, node b) { return a.a < b.a; }
bool ok(double c) {
  double maxn = 0;
  for (int i = 1, j; i <= n; i = j) {
    double sum = 0;
    for (j = i; j <= n && a[i].a == a[j].a; j++) {
      if (a[j].a * (1 - c * a[j].r / s[n]) < maxn) return 0;
      sum = max(sum, a[j].a * (1 - c * a[j].l / s[n]));
    }
    maxn = max(maxn, sum);
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i].a);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i].t);
  sort(a + 1, a + 1 + n, cmp);
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i].t;
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && a[i].a * a[j].t == a[j].a * a[i].t; j++)
      ;
    for (int k = i; k < j; k++) a[k].l = s[i - 1] + a[k].t, a[k].r = s[j - 1];
  }
  sort(a + 1, a + 1 + n, cmp2);
  while (r - l > eps) {
    double m = (l + r) / 2;
    if (ok(m))
      l = m;
    else
      r = m;
  }
  printf("%.11lf", l);
}
