#include <bits/stdc++.h>
using namespace std;
long long n, a[51], b[51], f[51][51][51];
bool check(long long x) {
  memset(f, 0x3f, sizeof(f));
  long long INF = f[0][0][0];
  f[0][0][0] = 0;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < i; j++)
      if (a[i] == a[i - 1])
        for (long long k = 0; j + k <= i; k++) {
          f[i][j][k] = f[i - 1][j + 1][k];
          if (k && f[i - 1][j][k - 1] != INF)
            f[i][j][k] = min(f[i][j][k], f[i - 1][j][k - 1] + a[i] - x * b[i]);
        }
      else
        for (long long k = 0; k <= j + 1; k++) {
          f[i][j][0] = min(f[i][j][0], f[i - 1][k][j - k + 1]);
          if (k <= j && f[i - 1][k][j - k] != INF)
            f[i][j][1] = min(f[i][j][1], f[i - 1][k][j - k] + a[i] - x * b[i]);
        }
  for (long long j = 0; j < n; j++)
    for (long long k = 0; j + k <= n; k++)
      if (f[n][j][k] <= 0) return true;
  return false;
}
int main() {
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; i++) scanf("%I64d", &a[i]), a[i] *= 1000ll;
  for (long long i = 1; i <= n; i++) scanf("%I64d", &b[i]);
  for (long long i = 1; i <= n; i++)
    for (long long j = i + 1; j <= n; j++)
      if (a[i] < a[j]) swap(a[i], a[j]), swap(b[i], b[j]);
  long long l = 1, r = 2500000000000ll, mid;
  while (l < r) {
    mid = l + r >> 1ll;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  return printf("%I64d\n", l), 0;
}
