#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int N = 1e3 + 6;
const long long linf = 1e13 + 5;
int wh[N], n, m, x, y, z, bef[N];
pair<int, int> a[N];
int b[N], S[N];
vector<int> v[N];
long long dp[61][5005][61];
long long f(int x, int sum, int left) {
  if (sum < 0) return linf;
  if (x == 0) {
    if (sum == 0) return 0;
    return linf;
  }
  long long &r = dp[x][sum][left];
  if (r != -1) return r;
  r = linf;
  int sz = v[x].size();
  long long sum1 = 0, sum2 = 0;
  if (left >= sz) r = f(x - 1, sum, left - sz);
  for (int i = sz - 1; i >= 0; i--) {
    sum1 += v[x][i];
    sum2 += wh[x];
    if (left >= i) r = min(r, f(x - 1, sum - sum1, left - i + (sz - i)) + sum2);
  }
  return r;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].first);
  }
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].second);
  sort(a + 1, a + n + 1);
  int s = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i].first != a[i - 1].first) s++;
    v[s].push_back(a[i].second);
    wh[s] = a[i].first;
  }
  for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  memset(dp, -1, sizeof dp);
  long long ans = linf;
  for (int j = n; j <= n * 100; j++) {
    ans = min(ans,
              (long long)ceil(f(s, j, 0) / (1.0 * j) * 1000.0 - 0.0000000001));
  }
  cout << ans << endl;
  return 0;
}
