#include <bits/stdc++.h>
using namespace std;
int n;
pair<long long, long long> task[60];
long double dp[60][60][60];
long double ckmin(long double &a, long double b) { return a = min(a, b); }
bool check(long double val) {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        dp[i][j][k] = 0x3f3f3f3f3f3f3f3f;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    long double pp = task[i].first - task[i].second * val;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (task[i].first == task[i + 1].first) {
          ckmin(dp[i + 1][j][k + 1], dp[i][j][k] + pp);
        } else {
          ckmin(dp[i + 1][j + k + 1][0], dp[i][j][k] + pp);
        }
        if (j > 0) {
          ckmin(dp[i + 1][j - 1][k], dp[i][j][k]);
        }
      }
    }
  }
  long double ans = 0x3f3f3f3f3f3f3f3f;
  for (int j = 0; j <= n; j++) {
    ckmin(ans, dp[n][j][0]);
  }
  return ans <= 1e-8;
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> task[i].first;
  }
  for (int i = 0; i < n; i++) {
    cin >> task[i].second;
  }
  sort(task, task + n, greater<pair<long long, long long>>());
  long double l = 0;
  long double r = 0x3f3f3f3f3f3f3f3f;
  long long ans = -1;
  for (int i = 0; i < 200; i++) {
    long double m = (l + r) / 2;
    bool res = check(m);
    if (res) {
      ans = (long long)(ceil(1000 * m));
      r = m;
    } else {
      l = m;
    }
  }
  cout << ans << '\n';
  return 0;
}
