#include <bits/stdc++.h>
using namespace std;
struct E {
  int a, b;
  bool operator<(E o) const {
    if (a == o.a) return b < o.b;
    return a > o.a;
  }
} e[77];
long long dp[60][60];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> e[i].a;
  for (int i = 0; i < n; i++) cin >> e[i].b;
  sort(e, e + n);
  memset(dp, 0x7F, sizeof(dp));
  long long l = 0, r = 100000000000000ll, lm = dp[0][0];
  while (l + 1 < r) {
    auto m = (l + r) / 2;
    memset(dp, 0x7F, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
      int k = i + 1;
      long long suma = e[i].a, sumb = e[i].b;
      while (k < n && e[k].a == e[i].a) {
        suma += e[k].a;
        sumb += e[k].b;
        k++;
      }
      for (int j = 0; j <= i; j++)
        if (dp[i][j] < lm) {
          auto ta = suma, tb = sumb;
          for (int l = 0; l <= min(j, k - i); l++) {
            long long t = dp[i][j] + ta * 1000 - m * tb;
            if (dp[k][j + k - i - 2 * l] > t) dp[k][j + k - i - 2 * l] = t;
            ta -= e[i + l].a;
            tb -= e[i + l].b;
          }
        }
      i = k - 1;
    }
    bool check = true;
    for (int i = 0; i <= n; i++)
      if (dp[n][i] <= 0) {
        check = false;
      }
    if (check)
      l = m;
    else
      r = m;
  }
  cout << r << '\n';
}
