#include <bits/stdc++.h>
using namespace std;
const int maxn = 53, maxsum = 5300;
const long long inf = 1e18;
long long dp[maxn][maxsum], tmp[maxn][maxsum];
map<int, vector<int> > mp;
pair<int, int> p[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &p[i].first);
  for (int i = 0; i < n; i++) scanf("%d", &p[i].second);
  for (int i = 0; i < n; i++) mp[p[i].first].push_back(p[i].second);
  memset(dp, 63, sizeof dp);
  dp[0][0] = 0;
  for (auto it = mp.rbegin(); it != mp.rend(); it++) {
    auto P = *it;
    vector<int> &vec = P.second;
    sort(vec.begin(), vec.end(), greater<int>());
    memset(tmp, 63, sizeof tmp);
    for (int i = int((vec).size()); i < maxn; i++) {
      for (int j = 0; j < maxsum; j++) tmp[i - int((vec).size())][j] = dp[i][j];
    }
    int sm = 0;
    for (int tl = 0; tl < int((vec).size()); tl++) {
      sm += vec[tl];
      for (int i = int((vec).size()) - tl - 1; i < maxn; i++) {
        for (int j = 0; j < maxsum; j++) {
          if (j + sm >= maxsum || (i - int((vec).size()) + 2 * tl + 2) >= maxn)
            continue;
          long long &A = tmp[i - int((vec).size()) + 2 * tl + 2][j + sm],
                    B = dp[i][j] + 1ll * P.first * (tl + 1);
          A = min(A, B);
        }
      }
    }
    for (int i = 0; i < maxn; i++)
      for (int j = 0; j < maxsum; j++) dp[i][j] = tmp[i][j];
  }
  long double ans = inf;
  for (int i = 0; i < maxn; i++) {
    for (int j = 1; j < maxsum; j++) {
      ans = min(ans, long double(dp[i][j]) / long double(j));
      if (ans == 8) {
        cout << i << " " << j << " " << dp[i][j] << endl;
        return 0;
      }
    }
  }
  long long ANS = (ans + 0.0005) * 1000;
  printf("%lld\n", ANS);
  return 0;
}
