#include <bits/stdc++.h>
using namespace std;
const double INF = 1E18;
const double EPS = 1e-9;
const int MAXN = 2E5 + 10;
int n;
double c, c0 = INF;
pair<long long, long long> a[MAXN];
pair<long long, pair<long long, long long> > b[MAXN];
double T = 0;
long long vmult(pair<long long, long long> x, pair<long long, long long> y) {
  return x.second * y.first - x.first * y.second;
}
bool cmp(pair<long long, long long> x, pair<int, int> y) {
  if (vmult(x, y) == 0) return x.first < y.first;
  return vmult(x, y) < 0;
}
double f(long long first, long long second) {
  return first * (1 - c * second / T);
}
bool check() {
  double max = 0;
  for (int i = 0; i < n;) {
    double oldmax = max;
    double first = b[i].first;
    for (; i < n && b[i].first == first; i++) {
      if (f(first, b[i].second.second) < oldmax) {
        return false;
      }
      if (max < f(first, b[i].second.first)) max = f(first, b[i].second.first);
    }
  }
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i].second;
    T += a[i].second;
  }
  sort(a, a + n, cmp);
  double second = 0;
  for (int i = 0; i < n;) {
    double oldt = second;
    second += a[i].second;
    pair<long long, long long> x = a[i];
    for (int j = i + 1; j < n && vmult(x, a[j]) == 0; j++) {
      second += a[j].second;
    }
    for (; i < n && vmult(x, a[i]) == 0; i++) {
      b[i].first = a[i].first;
      b[i].second.first = oldt + a[i].second;
      b[i].second.second = second;
    }
  }
  sort(b, b + n);
  double l = 0, r = 1;
  while ((r - l) > EPS) {
    c = (l + r) / 2;
    if (check()) {
      l = c;
    } else {
      r = c;
    }
  }
  printf("%.9lf\n", min(c0, c));
}
