#include <bits/stdc++.h>
using namespace std;
struct vec {
  long double x, y;
  bool operator==(const vec &a) const { return x == a.x && y == a.y; }
  bool operator<(const vec &a) const {
    if (a.x != x) return x < a.x;
    return y < a.y;
  }
  vec operator+(const vec &a) const { return {x + a.x, y + a.y}; }
  vec operator*(const long double &a) const { return {x * a, y * a}; }
  vec operator-(const vec &a) const { return {x - a.x, y - a.y}; }
  vec operator/(const long double &a) const { return {x / a, y / a}; }
  long double len() const { return sqrt(x * x + y * y); }
  long double dot(const vec &a) const { return x * a.x + y * a.y; }
  long double crs(const vec &a) const { return x * a.y - y * a.x; }
  vec proj(const vec &a) const {
    return (a / a.len()) * (*this).dot(a) / a.len();
  }
};
struct P {
  int x, y, z;
  bool operator<(const P &a) const { return x < a.x; }
};
bool as(P a, P b) { return a.y > b.y; }
long long x, y, z, mod = 998244353;
vector<int> v, v1[55];
int i, n, m, k, a, d, b, c;
int e;
long long o[51][5111][111];
int l[1];
int j[1];
stack<int> s;
queue<int> q;
P u[51];
char r[1];
map<int, int> p, p1;
long long f(int n, int m, int c) {
  if (m < 0 || c < 0) return 987654321987;
  if (n == 0) {
    if (m == 0) return 0;
    return 987654321987;
  }
  if (o[n][m][c]) return o[n][m][c];
  int p = 0;
  o[n][m][c] = 987654321987;
  for (int h = 0; h < v1[n].size(); h++)
    if (c >= (v1[n].size() - h)) {
      o[n][m][c] = min(o[n][m][c], f(n - 1, m - p, c - v1[n].size() + h + h) +
                                       (long long)(h)*v[n]);
      p += v1[n][h];
    } else
      p += v1[n][h];
  return o[n][m][c] = min(o[n][m][c], f(n - 1, m - p, c + v1[n].size()) +
                                          (long long)(v1[n].size()) * v[n]);
}
int main() {
  scanf("%d", &a);
  for (int t = 1; t <= a; v.push_back(u[t].x), t++) scanf("%d", &u[t].x);
  for (int t = 1; t <= a; t++) scanf("%d", &u[t].y);
  v.push_back(0);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int h = 1; h < v.size(); h++) p[v[h]] = h;
  sort(u + 1, u + a + 1, as);
  for (int t = 1; t <= a; t++) {
    u[t].x = p[u[t].x];
    v1[u[t].x].push_back(u[t].y);
  }
  x = 1, y = 987654321987;
  for (; x < y;) {
    long long h = (x + y) / 2;
    for (int i = 1; i <= 5000; i++)
      if (h * i >= f(a, i, 0) * 1000) {
        y = h;
        goto qwe;
      }
    x = h + 1;
  qwe:;
  }
  printf("%lld", x);
}
