#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  while (a > 0) {
    b %= a;
    swap(a, b);
  }
  return b;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sign(T a) {
  return a > 0 ? 1 : (a < 0 ? -1 : 0);
}
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &p) {
  return out << "(" << p.first << ", " << p.second << ")";
};
template <class A>
ostream &operator<<(ostream &out, const vector<A> &v) {
  out << "[";
  for (int i = int(0); i < int(int((v).size())); ++i) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
mt19937 myRand(time(NULL));
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int dxK[] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int dyK[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dxKn[] = {-2, -1, 1, 2, 2, 1, -1, -2};
const int dyKn[] = {1, 2, 2, 1, -1, -2, -2, -1};
const int INF = int(1e9) + 100;
const long long INF64 = long long(1e18) + 100;
const long double EPS = 1e-9;
const long double PI = acosl(-1.0);
const int N = 55;
int n;
pair<int, int> p[N];
long long dp[N][N][N * 100];
inline bool read() {
  if (!(cin >> n)) return false;
  for (int i = int(0); i < int(n); ++i) cin >> p[i].first;
  for (int i = int(0); i < int(n); ++i) cin >> p[i].second;
  return true;
}
void upd(long long &a, long long b) { a = min(a, b); }
inline void solve() {
  sort(p, p + n);
  reverse(p, p + n);
  for (int i = int(0); i < int(N); ++i)
    for (int j = int(0); j < int(N); ++j)
      for (int k = int(0); k < int(N * 100); ++k) dp[i][j][k] = INF64;
  dp[0][0][0] = 0;
  for (int l = int(0); l < int(n); ++l)
    for (int rem = int(0); rem < int(N); ++rem)
      for (int bb = int(0); bb < int(N * 100); ++bb) {
        long long res = dp[l][rem][bb];
        if (res > INF64 / 2) continue;
        if (l > 0 && p[l].first == p[l - 1].first) break;
        int r = l + 1;
        long long suma = p[l].first;
        int sumb = p[l].second;
        while (r < n && p[r].first == p[l].first) {
          suma += p[r].first;
          sumb += p[r].second;
          ++r;
        }
        for (int c2 = int(0); c2 < int(r - l + 1); ++c2) {
          int c1 = r - l - c2;
          int nrem = rem + c1 - c2;
          int npos = r;
          int nbb = bb + sumb;
          if (nrem >= 0 && rem >= c2) upd(dp[npos][nrem][nbb], res + suma);
          suma -= p[c2 + l].first;
          sumb -= p[c2 + l].second;
        }
      }
  long long res = INF64;
  for (int rem = int(0); rem < int(n + 1); ++rem)
    for (int bb = 1; bb < int(n * 100 + 1); ++bb) {
      long long cur = dp[n][rem][bb];
      upd(res, (cur * 1000 + bb - 1) / bb);
    }
  cout << res << endl;
}
int main() {
  cout << fixed << setprecision(15);
  cerr << fixed << setprecision(15);
  int tc = 1;
  while (tc--) {
    read();
    solve();
  }
  return 0;
}
