#include <bits/stdc++.h>
using namespace std;
long long int n;
long long int a[55], b[55];
long long int R;
long long int at[55];
long long int cur = 1;
long long int dp[55][55];
vector<long long int> c[55];
map<long long int, vector<long long int>> m;
long long int rec(long long int i, long long int j) {
  if (i < 1) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  long long int mi = max((long long int)c[i].size() - j, 0ll);
  long long int an = 1e18;
  for (long long int h = mi; h <= c[i].size(); h++) {
    if (h == 0) {
      an = min(an, rec(i - 1, j - c[i].size()));
      continue;
    }
    an = min(an,
             rec(i - 1, j + h - c[i].size() + h) + h * at[i] - R * c[i][h - 1]);
  }
  return dp[i][j] = an;
}
long long int binsearch() {
  long long int l = 1, r = 1e12;
  long long int mid = (l + r) >> 1;
  while (r - l > 1) {
    R = mid;
    memset(dp, -1, sizeof dp);
    if (rec(cur, 0) <= 0)
      r = mid;
    else
      l = mid;
    mid = (l + r) >> 1;
  }
  R = mid;
  memset(dp, -1, sizeof dp);
  while (rec(cur, 0) > 0) {
    mid++;
    R = mid;
    memset(dp, -1, sizeof dp);
  }
  return mid;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) m[a[i] * 1000].push_back(b[i]);
  for (auto j : m) {
    at[cur] = j.first;
    sort(j.second.begin(), j.second.end());
    reverse(j.second.begin(), j.second.end());
    c[cur] = j.second;
    for (int h = 1; h < c[cur].size(); h++) c[cur][h] += c[cur][h - 1];
    cur++;
  }
  cur--;
  cout << binsearch() << '\n';
  return 0;
}
