#include <bits/stdc++.h>
using namespace std;
const int N = 55;
int n, a[N], b[N];
vector<pair<long long, long long>> v;
const long long inf = 1e18;
long long dp[N][N][N], vl[N];
bool good(long long goal) {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      for (int k = 0; k < N; k++) dp[i][j][k] = inf;
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    long long g = v[i].first - goal * v[i].second;
    for (int jj = 0; jj <= i; jj++)
      for (int kk = 0; jj + kk <= i; kk++) {
        if (dp[i][jj][kk] == inf) continue;
        int nj = jj, nk = kk;
        if (i == 0 or v[i].first != v[i - 1].first) nj += nk, nk = 0;
        dp[i + 1][nj][nk + 1] = min(dp[i + 1][nj][nk + 1], dp[i][jj][kk] + g);
        if (nj)
          dp[i + 1][nj - 1][nk] = min(dp[i + 1][nj - 1][nk], dp[i][jj][kk]);
      }
  }
  long long ans = inf;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) ans = min(ans, dp[n][i][j]);
  return ans <= 0;
}
int main() {
  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]);
  for (int i = 0; i < n; i++) v.push_back({a[i] * 1000LL, b[i]});
  sort(v.begin(), v.end(),
       [&](pair<long long, long long>& p1, pair<long long, long long>& p2) {
         if (p1.first != p2.first) return p1.first > p2.first;
         return p1.second > p2.second;
       });
  long long bl = 0, br = 1e12, ans = 1;
  while (bl <= br) {
    long long bmid = (bl + br) >> 1;
    if (good(bmid))
      br = bmid - 1, ans = bmid;
    else
      bl = bmid + 1;
  }
  printf("%lld\n", ans);
}
