#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int N = 52, V = N * 100 + 5;
long long dp[N][N][N], l = 0, h = 1e15, mid, ans = h;
int n;
struct O {
  long long a, b;
  bool operator<(const O& o) const { return a > o.a; }
} os[N];
long long f(int i, int j, int k) {
  if (i == n) return 0;
  long long& r = dp[i][j][k];
  if (r != -1) return r;
  bool nxt_same = i != n - 1 && os[i].a == os[i + 1].a;
  int j0 = nxt_same ? 0 : k, k0 = nxt_same ? k : 0;
  int j1 = nxt_same ? 0 : k + 1, k1 = nxt_same ? k + 1 : 0;
  r = f(i + 1, j1 + j, k1) + os[i].a * 1000LL - mid * os[i].b;
  if (j) r = min(r, f(i + 1, j - 1 + j0, k0));
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int x = 0, qwerty = n; x < qwerty; x++) cin >> os[x].a;
  for (int x = 0, qwerty = n; x < qwerty; x++) cin >> os[x].b;
  sort(os, os + n);
  while (h >= l) {
    mid = (l + h) / 2;
    memset(dp, -1, sizeof(dp));
    if (f(0, 0, 0) <= 0) {
      ans = min(ans, mid);
      h = mid - 1;
    } else
      l = mid + 1;
  }
  cout << ans << "\n";
}
