#include <bits/stdc++.h>
const long long INF = 199999999999;
const int MAXN = 55;
using namespace std;
int n;
pair<long long, long long> a[MAXN];
long long l, r, m;
long long c[MAXN];
long long f[MAXN][MAXN][MAXN];
void relax(long long &a, long long b) {
  if (b < a) a = b;
}
bool check(long long value) {
  for (int i = 1; i <= n; ++i) c[i] = a[i].first - a[i].second * value;
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k <= n; ++k) f[i][j][k] = INF;
  f[0][0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j <= i; ++j)
      for (int k = 0; j + k <= i; ++k)
        if (f[i][j][k] != INF) {
          int jj = j, kk = k;
          if (a[i + 1].first != a[i].first) {
            jj = 0;
            kk = j + k;
          }
          relax(f[i + 1][jj][max(0, kk - 1)], f[i][j][k] + c[i + 1]);
          relax(f[i + 1][jj + 1][kk], f[i][j][k]);
        }
  return f[n][0][0] <= 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) cin >> a[i].first;
  for (int i = 1; i <= n; ++i) cin >> a[i].second;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) a[i].first *= 1000;
  for (int i = 1; i <= n; ++i) r = max(r, a[i].first);
  while (l < r) {
    long long m = (l + r) / 2;
    if (check(m))
      r = m;
    else
      l = m + 1;
  }
  cout << l << endl;
  return 0;
}
