#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int s = 0, c = 0, cmn = 0;
  int r[n], d[n];
  for (int i = 0; i < n; i++) cin >> r[i];
  for (int i = 0; i < n; i++) cin >> d[i];
  for (int i = 0; i < n; i++) {
    if (r[i] == 1 && d[i] == 1) cmn++;
    if (r[i] == 1 && d[i] == 0) c++;
    s += d[i];
  }
  if (c == 0 || cmn == n)
    cout << -1 << endl;
  else {
    s -= cmn;
    cout << (s / c) + 1 << endl;
  }
}
