#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1);
const long long INFF = 1e18;
const int INF = 1e9 + 1;
const int mod = 1e9 + 7;
const int MAX = 1e2 + 7;
int n;
pair<long long, long long> a[MAX];
long long dp[MAX][MAX][MAX];
bool sol(long long v) {
  for (int i = 0; i < (n + 1); ++i)
    for (int j = 0; j < (n + 1); ++j)
      for (int k = 0; k < (n + 1); ++k) dp[i][j][k] = -INFF;
  dp[0][0][0] = 0;
  for (int i = (1); i < (n + 1); ++i) {
    for (int j = 0; j < (i + 1); ++j)
      for (int k = 0; k < (i + 1); ++k) {
        if (dp[i - 1][j][k] == -INFF) continue;
        if (a[i].first == a[i + 1].first) {
          dp[i][j][k + 1] = max(dp[i][j][k + 1],
                                dp[i - 1][j][k] + v * a[i].second - a[i].first);
          if (j) dp[i][j - 1][k] = max(dp[i][j - 1][k], dp[i - 1][j][k]);
        } else {
          dp[i][j + 1 + k][0] =
              max(dp[i][j + 1 + k][0],
                  dp[i - 1][j][k] + v * a[i].second - a[i].first);
          if (j)
            dp[i][j - 1 + k][0] = max(dp[i][j - 1 + k][0], dp[i - 1][j][k]);
        }
      }
  }
  for (int i = 0; i < (n + 1); ++i)
    for (int j = 0; j < (n + 1); ++j)
      if (dp[n][i][j] >= 0) return 1;
  return 0;
}
int main(void) {
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) scanf("%lld", &a[i].first);
  for (int i = (1); i < (n + 1); ++i) scanf("%lld", &a[i].second);
  for (int i = (1); i < (n + 1); ++i) a[i].first *= 1000;
  sort(a + 1, a + n + 1, greater<pair<long long, long long> >());
  long long ll = 1, rr = 1e13, ans = 1e13;
  while (ll <= rr) {
    long long mid = (ll + rr) >> 1;
    if (sol(mid))
      rr = mid - 1, ans = mid;
    else
      ll = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
