#include <bits/stdc++.h>
using namespace std;
int n, in;
vector<long long> a;
vector<int> b;
vector<pair<long long, int>> cur;
int main() {
  cin >> n;
  for (int i = 0; i < (n << 1); i++) {
    cin >> in;
    if (i < n)
      a.push_back(in);
    else
      b.push_back(in);
  }
  for (int i = 0; i < n; i++) a[i] *= 1000;
  for (int i = 0; i < n; i++) cur.push_back(make_pair(a[i], b[i]));
  sort(a.begin(), a.end());
  int t = 1;
  for (int i = 1; i < n; i++)
    if (a[i] != a[i - 1]) t++;
  long long lo = 0, hi = 1e12;
  while (hi - lo > 1) {
    long long mid = (hi + lo) >> 1;
    long long res = LLONG_MAX;
    vector<vector<long long>> dp(t + 1, vector<long long>(n + 1, LLONG_MAX));
    dp[0][0] = 0;
    vector<pair<long long, long long>> c;
    for (int i = 0; i < n; i++)
      c.push_back(make_pair(cur[i].first, cur[i].first - mid * cur[i].second));
    sort(c.begin(), c.end());
    reverse(c.begin(), c.end());
    vector<vector<long long>> pref(t, vector<long long>(1, 0LL));
    int l = 0;
    for (int i = 0; i < n; i++) {
      if (i > 0 && c[i].first != c[i - 1].first) l++;
      pref[l].push_back(pref[l].back() + c[i].second);
    }
    for (int i = 1; i <= t; i++) {
      int sz = pref[i - 1].size() - 1;
      for (int j = 0; j <= sz; j++) {
        long long add = pref[i - 1][sz] - pref[i - 1][j];
        for (int u = j; u <= n; u++) {
          if (dp[i - 1][u] == LLONG_MAX) continue;
          dp[i][u - j + sz - j] =
              min(dp[i][u - j + sz - j], dp[i - 1][u] + add);
        }
      }
    }
    for (int i = 0; i <= n; i++) res = min(res, dp[t][i]);
    if (res <= 0)
      hi = mid;
    else
      lo = mid;
  }
  cout << hi << endl;
  return 0;
}
