#include <bits/stdc++.h>
using namespace std;
struct Fraction {
  long long num, den;
  Fraction() : num(0), den(1) {}
  Fraction(long long x, long long y) : num(x), den(y) {}
  bool operator<(const Fraction& other) const {
    return num * other.den < den * other.num;
  }
};
bool comp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first != b.first) {
    return a.first > b.first;
  }
  return a.second < b.second;
}
long long get(int lf, int rg, const vector<long long>& pref) {
  if (lf > rg) {
    return 0;
  }
  long long ans = pref[rg];
  if (lf - 1 >= 0) {
    ans -= pref[lf - 1];
  }
  return ans;
}
const int nmax = 55;
const int dmax = 110 * 55 + 10;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
  }
  for (int i = 0; i < n; ++i) {
    cin >> a[i].second;
  }
  sort((a).begin(), (a).end(), comp);
  vector<long long> p1(n);
  p1[0] = a[0].first;
  for (int i = 1; i < n; ++i) {
    p1[i] = p1[i - 1] + a[i].first;
  }
  vector<long long> p2(n);
  p2[0] = a[0].second;
  for (int i = 1; i < n; ++i) {
    p2[i] = p2[i - 1] + a[i].second;
  }
  vector<vector<long long> > dp(nmax, vector<long long>(dmax, -1));
  dp[0][0] = 0;
  int ptr = 0;
  while (ptr < n) {
    int lf = ptr;
    int rg = ptr;
    while (rg + 1 < (int)(a).size() && a[rg + 1].first == a[rg].first) {
      ++rg;
    }
    vector<vector<long long> > nx(nmax, vector<long long>(dmax, -1));
    for (int s = 0; s <= n; ++s) {
      for (int d = 0; d < dmax; ++d) {
        if (dp[s][d] == -1) {
          continue;
        }
        for (int z = 0; z <= s && z <= rg - lf + 1; ++z) {
          long long x = dp[s][d], y = d;
          x += get(lf + z, rg, p1);
          y += get(lf + z, rg, p2);
          int r = s - z + (rg - lf + 1 - z);
          if (nx[r][y] == -1 || x < nx[r][y]) {
            nx[r][y] = x;
          }
        }
      }
    }
    dp.swap(nx);
    ptr = rg + 1;
  }
  Fraction ans = Fraction(-1, 1);
  for (int s = 0; s <= n; ++s) {
    for (int d = 0; d < dmax; ++d) {
      if (dp[s][d] == -1) {
        continue;
      }
      Fraction val = Fraction(dp[s][d], d);
      if (ans.num == -1 || val < ans) {
        ans = val;
      }
    }
  }
  long long x = ans.num, y = ans.den;
  x *= 1000;
  cout << (x + y - 1) / y << "\n";
}
