#include <bits/stdc++.h>
using namespace std;
const int N = 51;
const long long int INF = 1e18;
int a[N], b[N];
long long int dp[N][N][N * 100];
map<int, vector<int>> mp;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    mp[a[i]].push_back(b[i]);
  }
  for (auto &p : mp) {
    sort(p.second.rbegin(), p.second.rend());
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N * 100; k++) {
        dp[i][j][k] = INF;
      }
    }
  }
  dp[0][0][0] = 0;
  auto it = mp.rbegin();
  for (int i = 0; i < mp.size(); i++, it++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n * 100; k++) {
        if (dp[i][j][k] < INF) {
          if (j >= it->second.size()) {
            dp[i + 1][j - it->second.size()][k] =
                min(dp[i + 1][j - it->second.size()][k], dp[i][j][k]);
          }
          for (int t = 0, s = 0; t < it->second.size(); t++) {
            s += it->second[t];
            if (j - (int)it->second.size() + t + 1 < 0) continue;
            int nj = j + t + t + 2 - (int)it->second.size();
            dp[i + 1][nj][k + s] =
                min(dp[i + 1][nj][k + s], dp[i][j][k] + it->first * (t + 1ll));
          }
        }
      }
    }
  }
  long long int ans = INF;
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= n * 100; j++) {
      if (dp[mp.size()][i][j] < INF) {
        long long int cur = ceil(dp[mp.size()][i][j] * 1000 / j);
        ans = min(ans, cur);
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
