#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
long long n;
pair<long long, long long> a[101];
double A[101];
double f[51][51][51];
double dp(long long pos, long long lar, long long equa) {
  if (pos == n + 1) return 0;
  if (f[pos][lar][equa] != -1) return f[pos][lar][equa];
  double cur = 1e18;
  if (a[pos + 1] != a[pos])
    cur = min(cur, dp(pos + 1, lar + equa + 1, 0) + A[pos]);
  else
    cur = min(cur, dp(pos + 1, lar, equa + 1) + A[pos]);
  if (lar) {
    if (A[pos + 1] != A[pos])
      cur = min(cur, dp(pos + 1, lar + equa - 1, 0));
    else
      cur = min(cur, dp(pos + 1, lar - 1, equa));
  }
  return f[pos][lar][equa] = cur;
}
bool check(double x) {
  for (long long i = 1; i <= n; i++) A[i] = a[i].first - x * a[i].second;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= n; j++)
      for (long long k = 0; k <= n; k++) f[i][j][k] = -1;
  double mn = dp(1, 0, 0);
  return (mn <= 0.0);
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i].first;
  for (long long i = 1; i <= n; i++) cin >> a[i].second;
  sort(a + 1, a + 1 + n, greater<pair<long long, long long> >());
  double l = 0, r = 1e18;
  double ans = -1;
  while (l <= r - EPS) {
    double mi = (l + r) / 2;
    if (check(mi)) {
      ans = mi;
      r = mi - EPS;
    } else
      l = mi + EPS;
  }
  ans *= 1000;
  cout << setprecision(0) << fixed << ans;
}
