#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
struct node {
  int x, y, z;
  bool operator<(const node& a) const {
    if ((long long)x * a.y != (long long)y * a.x)
      return (long long)x * a.y > (long long)y * a.x;
    return x < a.x;
  }
  bool operator==(const node& a) const {
    return (long long)x * a.y == (long long)y * a.x;
  }
  bool operator!=(const node& a) const {
    return (long long)x * a.y != (long long)y * a.x;
  }
} a[N];
int n, b[N];
long long sum;
const double eps = 1e-10;
int flag;
int c[N], d[N], le[N], ri[N];
long long pre[N];
void solve(int l, int r, double res) {
  if (!flag || c[l] == c[r]) return;
  int mid = (l + r) / 2;
  if (c[mid] == c[r]) {
    while (c[mid] == c[mid - 1]) --mid;
    --mid;
  }
  while (c[mid] == c[mid + 1]) ++mid;
  solve(l, mid, res);
  solve(mid + 1, r, res);
  double mx = -1. / 0., mn = 1. / 0.;
  for (int i = l; i <= mid; ++i)
    mx = max(mx, c[i] * (1 - res * (pre[le[i] - 1] + d[i]) / sum));
  for (int i = mid + 1; i <= r; ++i)
    mn = min(mn, c[i] * (1 - res * pre[ri[i]] / sum));
  if (mx > mn) flag = 0;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i].x, a[i].z = i, a[i].y = a[i].x;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) cin >> b[i], sum += b[i];
  for (int i = 1; i <= n; ++i)
    a[i].y = b[a[i].z], a[i].z = i, c[i] = a[i].x, d[i] = a[i].y;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + a[i].y;
  for (int i = 1; i <= n; ++i)
    if (i == 1 || a[i] != a[i - 1])
      le[a[i].z] = i;
    else
      le[a[i].z] = le[a[i - 1].z];
  for (int i = n; i; --i)
    if (i == n || a[i] != a[i + 1])
      ri[a[i].z] = i;
    else
      ri[a[i].z] = ri[a[i + 1].z];
  double l = 0, r = 1;
  while (r - l > eps) {
    double mid = (l + r) / 2;
    flag = 1;
    solve(1, n, mid);
    if (flag)
      l = mid;
    else
      r = mid;
  }
  printf("%.8lg\n", (l + r) / 2);
  return 0;
}
