#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[55], b[55];
long long p[55];
map<long long, vector<long long> > mp;
long long dp[55][55][55][55];
bool check(long long x) {
  mp.clear();
  for (long long(i) = (1); (i) <= (n); (i)++) p[i] = (x * b[i] - 1000 * a[i]);
  for (long long(i) = (1); (i) <= (n); (i)++) mp[-a[i]].push_back(p[i]);
  long long m = mp.size(), i = 0;
  for (auto p : mp) {
    vector<long long> &vec = p.second;
    for (long long(j) = (0); (j) <= ((int)vec.size()); (j)++) {
      for (long long(k) = (0); (k) <= (n); (k)++) {
        for (long long(l) = (0); (l) <= (n); (l)++) {
          dp[i][j][k][l] = -1e18;
        }
      }
    }
    i++;
  }
  for (long long(j) = (0); (j) <= (n); (j)++) {
    for (long long(k) = (0); (k) <= (n); (k)++) {
      for (long long(l) = (0); (l) <= (n); (l)++) {
        dp[m][j][k][l] = -1e18;
      }
    }
  }
  dp[0][0][0][0] = 0;
  i = 0;
  for (auto p : mp) {
    vector<long long> &vec = p.second;
    for (long long(j) = (0); (j) <= ((int)vec.size() - 1); (j)++) {
      for (long long(k) = (0); (k) <= (n); (k)++) {
        for (long long(l) = (0); (l) <= (n); (l)++) {
          (dp[i][j + 1][k][l + 1]) =
              max((dp[i][j + 1][k][l + 1]), (dp[i][j][k][l] + vec[j]));
          if (k - 1 >= 0)
            (dp[i][j + 1][k - 1][l]) =
                max((dp[i][j + 1][k - 1][l]), (dp[i][j][k][l]));
        }
      }
    }
    for (long long(k) = (0); (k) <= (n); (k)++) {
      for (long long(l) = (0); (l) <= (n); (l)++) {
        if (k + l <= n)
          (dp[i + 1][0][k + l][0]) =
              max((dp[i + 1][0][k + l][0]), (dp[i][(int)vec.size()][k][l]));
      }
    }
    i++;
  }
  long long ret = -1e18;
  for (long long(k) = (0); (k) <= (n); (k)++)
    (ret) = max((ret), (dp[m][0][k][0]));
  return ret >= 0;
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long(i) = (1); (i) <= (n); (i)++) cin >> a[i];
  for (long long(i) = (1); (i) <= (n); (i)++) cin >> b[i];
  long long ub = 2e11, lb = 0, mid;
  while (ub - lb > 1) {
    mid = (ub + lb) / 2;
    if (check(mid))
      ub = mid;
    else
      lb = mid;
  }
  cout << ub << endl;
  return 0;
}
