#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > adj(1234);
vector<pair<long long, long long> > vec;
long long counter = 0;
long long n;
map<long long, long long> mapi;
long long dp[100][100];
long long check(long long mid) {
  long long i, j, adder;
  for (i = 0; i < counter + 10; i++) {
    adj[i].clear();
  }
  for (i = 0; i < vec.size(); i++) {
    adder = vec[i].first - mid * vec[i].second;
    adj[mapi[vec[i].first]].push_back(adder);
  }
  for (i = 0; i < counter; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  long long iinf = (1000 * 1000 * 1000 + 5);
  iinf *= (1000 * 1000 * 1000 + 5);
  for (i = 0; i < n + 3; i++) {
    dp[counter][i] = iinf;
  }
  long long k;
  long long sumi = 0;
  dp[counter][0] = 0;
  for (i = counter - 1; i >= 0; i--) {
    for (j = 0; j < n + 1; j++) {
      sumi = 0;
      dp[i][j] = iinf;
      long long siz = adj[i].size();
      if (j + siz <= n) {
        dp[i][j] = dp[i + 1][j + siz];
      }
      for (k = 0; k < adj[i].size(); k++) {
        sumi += adj[i][k];
        k++;
        long long previ = j - k + siz - k;
        if (previ >= siz - k && previ >= 0 && previ <= n) {
          dp[i][j] = min(dp[i][j], dp[i + 1][previ] + sumi);
        }
        k--;
      }
    }
  }
  for (i = 0; i < n + 1; i++) {
    if (dp[0][i] <= 0) {
      return 1;
    }
  }
  return 0;
}
long long a[123], b[123];
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  long long i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    a[i] *= 1000;
    mapi[a[i]] = 1;
  }
  map<long long, long long>::iterator it;
  for (it = mapi.begin(); it != mapi.end(); it++) {
    it->second = counter++;
  }
  for (i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    vec.push_back(make_pair(a[i], b[i]));
  }
  sort(vec.begin(), vec.end());
  long long low = 0;
  long long high = (1000 * 1000 * 1000 + 5);
  high *= 1000;
  long long mid, ans;
  while (low <= high) {
    mid = (low + high) / 2;
    if (check(mid)) {
      ans = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
