#include <bits/stdc++.h>
using namespace std;
const int N = 200009;
const double eps = 0.00000000001;
int n, p[N], q[N], bb[N], c[N], L[N], R[N];
double b[N], fuck[N];
long long T;
struct test {
  int a, t;
  double b, f;
  bool operator<(const test &A) const {
    if (1. * a / t != 1. * A.a / A.t) return 1. * a / t > 1. * A.a / A.t;
    return a < A.a;
  }
  bool operator==(const test &A) const {
    return fabs(1. * a / t - 1. * A.a / A.t) < eps;
  }
} d[N];
struct BIT {
  double c[N];
  void build() {
    for (int i = 1; i <= n; i++) c[i] = 0;
  }
  int lowbit(int x) { return x & (-x); }
  void add(int x, double y) {
    while (x <= n) c[x] = max(c[x], y), x += lowbit(x);
  }
  double get(int x) {
    double ans = 0.;
    while (x) ans = max(c[x], ans), x -= lowbit(x);
    return ans;
  }
} B;
void LS() {
  for (int i = 1; i <= n; i++) bb[i] = d[i].a;
  sort(bb + 1, bb + 1 + n);
  int m = unique(bb + 1, bb + 1 + n) - (bb + 1);
  for (int i = 1; i <= n; i++)
    c[i] = lower_bound(bb + 1, bb + 1 + m, d[i].a) - bb;
}
void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &d[i].a);
  for (int i = 1; i <= n; i++) scanf("%d", &d[i].t), T += d[i].t;
}
bool cmp(int A, int B) { return d[A].a < d[B].a; }
bool check(double mid) {
  B.build();
  for (int i = 1; i <= n; i++) {
    if (B.get(c[p[i]] - 1) > d[p[i]].a * (1 - mid * (d[p[R[i]]].f) / T))
      return 0;
    B.add(
        c[p[i]],
        d[p[i]].a * (1 - mid * (d[p[L[i]]].f - d[p[L[i]]].t + d[p[i]].t) / T));
  }
  return 1;
}
bool cmp2(int a, int b) { return d[a] < d[b]; }
void work() {
  LS();
  for (int i = 1; i <= n; i++) p[i] = i;
  sort(p + 1, p + 1 + n, cmp2);
  for (int i = 1; i <= n; i++) d[p[i]].f = d[p[i - 1]].f + d[p[i]].t;
  int j;
  for (int i = 1; i <= n; i = j) {
    for (j = i + 1; d[p[j]] == d[p[i]] && j <= n; j++)
      ;
    for (int k = i; k < j; k++) L[k] = i, R[k] = j - 1;
  }
  double l = 0, r = 1, mid;
  while (r - l >= 0.000000001) {
    mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.8lf\n", l);
}
int main() {
  init();
  work();
  return 0;
}
