#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 50;
int n;
long long a[MAXN];
int b[MAXN];
long long c[MAXN];
int nc;
vector<int> who[MAXN];
vector<long long> vals[MAXN];
long long dp[MAXN + 1][MAXN + 1];
bool ok(long long x) {
  for (int i = (0); i < (nc); ++i) vals[i].clear();
  for (int i = (0); i < (nc); ++i)
    for (int j = (0); j < (((int)(who[i]).size())); ++j) {
      int id = who[i][j];
      vals[nc - i - 1].push_back(a[id] - x * b[id]);
    }
  for (int i = (0); i < (nc); ++i) sort(vals[i].begin(), vals[i].end());
  for (int i = (0); i <= (nc); ++i)
    for (int j = (0); j <= (n); ++j) dp[i][j] = LLONG_MAX;
  dp[0][0] = 0;
  for (int i = (0); i < (nc); ++i)
    for (int j = (0); j <= (n); ++j)
      if (dp[i][j] != LLONG_MAX)
        for (int k = (0); k <= (min(j, ((int)(vals[i]).size()))); ++k) {
          int ni = i + 1, nj = j - k + ((int)(vals[i]).size()) - k;
          long long ndp = dp[i][j];
          for (int l = (0); l < (((int)(vals[i]).size()) - k); ++l)
            ndp += vals[i][l];
          dp[ni][nj] = min(dp[ni][nj], ndp);
        }
  long long ans = LLONG_MAX;
  for (int j = (0); j <= (n); ++j) ans = min(ans, dp[nc][j]);
  return ans <= 0;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%lld", &a[i]), a[i] *= 1000;
  for (int i = (0); i < (n); ++i) scanf("%d", &b[i]);
  nc = 0;
  for (int i = (0); i < (n); ++i) c[nc++] = a[i];
  sort(c, c + nc);
  nc = unique(c, c + nc) - c;
  for (int i = (0); i < (n); ++i) {
    int idx = lower_bound(c, c + nc, a[i]) - c;
    who[idx].push_back(i);
  }
  long long l = 0, h = 0;
  for (int i = (0); i < (n); ++i) h = max(h, a[i]);
  while (l + 1 < h) {
    long long m = l + (h - l) / 2;
    if (ok(m))
      h = m;
    else
      l = m;
  }
  printf("%lld\n", h);
}
int main() {
  run();
  return 0;
}
