#include <bits/stdc++.h>
int n, b[1000005], ml[1000005], mr[1000005], min_id[1000005], min_t[1000005],
    max_id[1000005];
double num[1000005], T[1000005], total;
using std::vector;
vector<int> V[1000005];
int read() {
  char c = getchar();
  int ans = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans;
}
struct data {
  int s, t;
  bool operator<(const data b) const {
    return (s + 0ll) * b.t > (b.s + 0ll) * t;
  }
  bool operator==(const data b) const {
    return (s + 0ll) * b.t == (b.s + 0ll) * t;
  }
} G[1000005];
double max(double u, double v) { return u > v ? u : v; }
double min(double u, double v) { return u < v ? u : v; }
namespace BIT {
double maxn[1000005];
void build() {
  for (register int i = 1; i <= n; i++) maxn[i] = -1e18;
  return;
}
void modify(int x, double y) {
  for (register int i = x; i <= n; i += (i & (-i))) maxn[i] = max(maxn[i], y);
  return;
}
double query(int x) {
  double ans = maxn[x];
  for (register int i = x; i; i &= (i - 1)) ans = max(ans, maxn[i]);
  return ans;
}
}  // namespace BIT
bool check(double c) {
  BIT::build();
  for (register int i = 1; i <= *b; i++) {
    if (BIT::query(max_id[i]) > b[i] * (1 - c * T[max_id[i]] / total)) return 0;
    BIT::modify(min_id[i],
                b[i] * (1 - c * (T[min_id[i] - 1] + min_t[i]) / total));
  }
  return 1;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) G[i].s = read(), b[++*b] = G[i].s;
  for (register int i = 1; i <= n; i++) G[i].t = read(), total += G[i].t;
  std::sort(G + 1, G + 1 + n), std::sort(b + 1, b + 1 + *b),
      *b = std::unique(b + 1, b + 1 + *b) - (b + 1);
  for (register int i = 1; i <= n; i++)
    if (i > 1 && G[i] == G[i - 1])
      ml[i] = ml[i - 1];
    else
      ml[i] = i;
  for (register int i = n; i >= 1; i--)
    if (i < n && G[i] == G[i + 1])
      mr[i] = mr[i + 1];
    else
      mr[i] = i;
  for (register int i = 1; i <= n; i++) {
    int id = std::lower_bound(b + 1, b + 1 + *b, G[i].s) - b;
    if (!min_id[id]) min_id[id] = ml[i], min_t[id] = G[i].t;
    max_id[id] = mr[i], min_t[id] = min(min_t[id], G[i].t);
  }
  for (register int i = 1; i <= n; i++) T[i] = T[i - 1] + G[i].t;
  double ml = 0.0, mr = 1.0;
  for (register int i = 1; i <= 40; i++) {
    double mid = (ml + mr) / 2;
    if (check(mid))
      ml = mid;
    else
      mr = mid;
  }
  printf("%.10lf", (ml + mr) / 2);
  return 0;
}
