#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;
int n, x, y, z, w[N];
double b[N], c[N], C;
pair<int, int> a[N];
long long all;
vector<int> v;
bool eq(int x, int y) {
  return (long long)a[x].first * a[y].second ==
         (long long)a[x].second * a[y].first;
}
bool cmp(int x, int y) {
  return (long long)a[x].first * a[y].second >
         (long long)a[x].second * a[y].first;
}
void calc(double x) {
  double cur = 0;
  for (int i = 1; i <= n; i++) {
    cur += a[w[i]].second;
    double g = a[w[i]].first * (1 - x * cur / all);
    c[w[i]] = g;
  }
}
bool ctr(double x) {
  C = x;
  double res = -1, sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i == n || 0 == eq(w[i], w[i + 1])) {
      double temp = sum, mx = -1;
      v.clear();
      for (int j = i; j >= 1; j--)
        if (eq(w[i], w[j])) {
          sum += a[w[j]].second;
          v.push_back(w[j]);
        } else
          break;
      sort(v.begin(), v.end());
      for (__typeof(v.begin()) it = v.begin(); it != v.end(); it++) {
        c[*it] = a[*it].first * (1.0 - C * sum / all);
        b[*it] = a[*it].first * (1.0 - C * (temp + a[*it].second) / all);
      }
    }
  }
  double mx = -1;
  int last = 1;
  for (int i = 1; i <= n; i++) {
    if (c[i] < mx) return false;
    if (a[i].first != a[i + 1].first) {
      for (int j = last; j <= i; j++) mx = max(mx, b[j]);
      last = i + 1;
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].first);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].second);
    all += a[i].second;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) w[i] = i;
  sort(w + 1, w + n + 1, cmp);
  double l = 0, r = 1;
  for (int i = 1; i <= 50; i++) {
    double mid = (l + r) / 2.0;
    if (ctr(mid))
      l = mid;
    else
      r = mid;
  }
  printf("%.12lf\n", l);
  return 0;
}
