#include <bits/stdc++.h>
long long num1[2000], num2[2000], num3[2000], sum[2000], p[2000];
long long th;
bool cmp(const long long &a, const long long &b) {
  long long t1, t2;
  if (num1[a] == num1[b]) {
    t1 = (long long)1000 * num1[a] - th * num2[a];
    t2 = (long long)1000 * num1[b] - th * num2[b];
    return t1 < t2;
  }
  return num1[a] > num1[b];
}
long long dp[2000][2000];
int main() {
  long long i, j, k, a, b, c, m, n, ans, l, li, ri, mid;
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &num1[i]);
    p[i] = i;
  }
  for (i = 1; i <= n; i++) {
    scanf("%lld", &num2[i]);
  }
  li = 0;
  ri = (long long)10000000000000;
  while (li <= ri) {
    mid = (li + ri) >> 1;
    th = mid;
    std::sort(p + 1, p + n + 1, cmp);
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        dp[i][j] = (long long)0xFFFFFFFFFFFFFF;
      }
    }
    for (i = 0; i <= n; i++) {
      dp[0][i] = 0;
    }
    for (i = 1, j = 0; i <= n; i++) {
      while ((i < n) && (num1[p[i + 1]] == num1[p[i]])) {
        i++;
      }
      sum[0] = 0;
      for (l = 1; l <= i - j; l++) {
        sum[l] = sum[l - 1] +
                 ((long long)1000 * num1[p[l + j]] - num2[p[l + j]] * th);
      }
      for (k = i / 2 + i % 2; k <= i; k++) {
        for (l = k - j;
             l <=
             (((2 * k - i) <
               ((((i - j) < (k - j / 2 - j % 2)) ? (i - j)
                                                 : (k - j / 2 - j % 2))))
                  ? (2 * k - i)
                  : ((((i - j) < (k - j / 2 - j % 2)) ? (i - j)
                                                      : (k - j / 2 - j % 2))));
             l++) {
          dp[i][k] = (((dp[i][k]) < (dp[j][k - l] + sum[l]))
                          ? (dp[i][k])
                          : (dp[j][k - l] + sum[l]));
        }
      }
      j = i;
    }
    a = 0;
    for (i = n / 2 + n % 2; i <= n; i++) {
      if (dp[n][i] <= 0) {
        a = 1;
        break;
      }
    }
    if (a) {
      ri = mid - 1;
    } else {
      li = mid + 1;
    }
  }
  printf("%lld\n", li);
  return 0;
}
