#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int ddx[] = {-1, -2, 1, -2, 2, -1, 2, 1}, ddy[] = {-2, -1, -2, 1, -1, 2, 1, 2};
pair<long long, long long> p[50];
int main() {
  int n;
  scanf("%d", &n);
  for (int(i) = (0); (i) <= (n - 1); (i) += (1)) {
    scanf("%lld", &p[i].first);
    p[i].first *= 1000;
  }
  for (int(i) = (0); (i) <= (n - 1); (i) += (1)) {
    scanf("%lld", &p[i].second);
  }
  if (n == 1) {
    return !printf("%lld\n", (p[0].first - 1) / p[0].second + 1);
  }
  sort(p, p + n);
  reverse(p, p + n);
  vector<pair<long long, long long> > v, vv;
  for (int(i) = (0); (i) <= ((n - 1) / 2); (i) += (1)) {
    v.push_back(p[i]);
  }
  long long c = v.back().first;
  int cnt = 0;
  for (auto P : v)
    if (P.first != c) cnt++;
  reverse(p, p + n);
  for (int(i) = (0); (i) <= (n / 2 - 1); (i) += (1)) {
    if (p[i].first == c && cnt == 0) {
      v.push_back(p[i]);
    } else {
      vv.push_back(p[i]);
      if (p[i].first == c) cnt--;
    }
  }
  long long sum1 = 0, sum2 = 0;
  for (pair<int, int> P : v) {
    sum1 += P.first, sum2 += P.second;
  }
  if (vv.empty()) {
    return !printf("%lld\n", (sum1 - 1) / sum2 + 1);
  }
  long long l = 0, r = 1e12;
  while (l <= r) {
    long long k = l + r >> 1;
    long long s1 = 0, s2 = 0;
    for (auto P : vv) {
      if (P.first - k * P.second <= 0) s1 += P.first, s2 += P.second;
    }
    if ((sum1 + s1) - k * (sum2 + s2) <= 0)
      r = k - 1;
    else
      l = k + 1;
  }
  printf("%lld\n", l);
}
