#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  x *= f;
}
struct S {
  int a, b;
} s[100];
bool cmp(S x, S y) {
  if (x.a != y.a) return x.a > y.a;
  return x.b > y.b;
}
struct T {
  int a, size[100];
  vector<int> vec;
} t[100];
int n, sum[100], cnt, sz[100], num[100];
const long long oo = 1e18;
inline void MN(long long &x, long long y) { x = min(x, y); }
long long dp[51][51][5005];
long double ans = 1e18;
int main() {
  read(n);
  for (int i = (1); i <= (n); ++i) read(s[i].a);
  for (int i = (1); i <= (n); ++i) read(s[i].b);
  sort(s + 1, s + n + 1, cmp);
  for (int i = (1); i <= (n); ++i) {
    if (i == 1) {
      cnt++;
      t[cnt].a = s[i].a;
      t[cnt].vec.push_back(s[i].b);
    } else if (s[i].a != s[i - 1].a) {
      cnt++;
      t[cnt].a = s[i].a;
      t[cnt].vec.push_back(s[i].b);
    } else
      t[cnt].vec.push_back(s[i].b);
  }
  for (int i = (1); i <= (cnt); ++i) {
    for (int j = (0); j <= ((int)t[i].vec.size() - 1); ++j)
      t[i].size[j + 1] = t[i].size[j] + t[i].vec[j];
  }
  for (int i = (1); i <= (cnt); ++i) num[i] = num[i - 1] + t[i].vec.size();
  for (int i = (1); i <= (cnt); ++i)
    sz[i] = sz[i - 1] + t[i].size[t[i].vec.size()];
  memset(dp, 0x7f, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = (1); i <= (cnt); ++i) {
    for (int j = (0); j <= (num[i - 1]); ++j)
      for (int k = (0); k <= (sz[i - 1]); ++k) {
        for (int l = (0); l <= (t[i].vec.size()); ++l)
          if (j >= t[i].vec.size() - l) {
            MN(dp[i][j - t[i].vec.size() + 2 * l][k + t[i].size[l]],
               dp[i - 1][j][k] + 1LL * l * t[i].a);
          }
      }
  }
  for (int i = (0); i <= (n); ++i)
    for (int j = (1); j <= (sz[cnt]); ++j)
      ans = min(ans, (long double)dp[cnt][i][j] / j * 1000);
  printf("%lld\n", (long long)ceil(ans));
  return 0;
}
