#include <bits/stdc++.h>
const long long inf = 1ll << 60;
int n;
struct item {
  int a, b;
  bool operator<(const item& it) const { return a < it.a; }
} S[55];
long long f[55][55][55];
void cmin(long long& a, long long b) { b < a ? a = b : 1; }
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &S[i].a);
  for (int i = 0; i < n; i++) scanf("%d", &S[i].b);
  std::sort(S, S + n);
  long long left = -1, right = 1ll << 40, mid;
  while (right - left > 1) {
    mid = left + right >> 1;
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= n; j++)
        for (int k = 0; k <= n; k++) f[i][j][k] = inf;
    f[n][0][0] = 0;
    for (int i = n; i; i--) {
      for (int j = 0; i + j <= n; j++) {
        for (int k = 0; i + j + k <= n; k++)
          if (f[i][j][k] < inf) {
            if (i < n && S[i - 1].a == S[i].a) {
              cmin(f[i - 1][j][k + 1],
                   f[i][j][k] + S[i - 1].a * 1000ll - mid * S[i - 1].b);
              if (j) cmin(f[i - 1][j - 1][k], f[i][j][k]);
            } else {
              cmin(f[i - 1][j + k][1],
                   f[i][j][k] + S[i - 1].a * 1000ll - mid * S[i - 1].b);
              if (j + k) cmin(f[i - 1][j + k - 1][0], f[i][j][k]);
            }
          }
      }
    }
    bool fl = 1;
    for (int j = 0; j <= n; j++)
      for (int k = 0; j + k <= n; k++)
        if (f[0][j][k] <= 0) {
          fl = 0;
        }
    if (fl)
      left = mid;
    else
      right = mid;
  }
  printf("%lld\n", right);
}
