#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  while (c < '0' || c > '9') {
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + (c ^ 48);
    c = getchar();
  }
  return x;
}
int n;
double T;
struct Test {
  double p, t;
  double first, last;
  double value;
} a[150001];
inline bool cmp(Test a, Test b) { return a.value > b.value; }
inline bool cmp_(Test a, Test b) { return a.p > b.p; }
inline bool check(double c) {
  double mins = 1e18;
  double mins_ = 1e18;
  for (int i = 1; i <= n; i++) {
    if (a[i].p * (1 - c * (a[i].first + a[i].t) / T) > mins) {
      return 0;
    }
    mins_ = min(mins_, a[i].p * (1 - c * a[i].last / T));
    if (a[i].p != a[i + 1].p) {
      mins = mins_;
    }
  }
  return 1;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i].p = read();
  }
  for (int i = 1; i <= n; i++) {
    a[i].t = read();
    T += a[i].t;
    a[i].value = a[i].p / a[i].t;
  }
  sort(a + 1, a + n + 1, cmp);
  double now = 0;
  double sum1 = 0, sum2 = 0;
  for (int i = 1; i <= n; i++) {
    if (now != a[i].value) {
      sum1 = sum2;
      now = a[i].value;
      int k = i - 1;
      while (a[++k].value == now) {
        sum2 += a[k].t;
      }
    }
    a[i].first = sum1;
    a[i].last = sum2;
  }
  sort(a + 1, a + n + 1, cmp_);
  double l = 0, r = 1;
  while (r - l >= 1e-12) {
    double mid = (l + r) / 2;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  printf("%.11lf", (l + r) / 2);
  return 0;
}
