#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
int n;
ll a[101];
ll b[101];
ll point[101];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  ll bpoint = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++)
    if (b[i]) {
      point[i] = 1;
      bpoint++;
    }
  ll ans = 1e9;
  ll mid, left = 1, right = bpoint + 1;
  while (left <= right) {
    ll apoint = 0;
    mid = (left + right) / 2;
    for (int i = 1; i <= n; i++) {
      if (point[i] == 0)
        apoint += mid * a[i];
      else
        apoint += point[i] * a[i];
    }
    if (apoint > bpoint) {
      ans = min(mid, ans);
      right = mid - 1;
    } else
      left = mid + 1;
  }
  if (ans == 1e9)
    cout << -1;
  else
    cout << ans;
}
