#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int r[n];
  for (int i = 0; i < n; i++) {
    cin >> r[i];
  }
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  int summ = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == 1) {
      summ++;
    }
  }
  int key = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] != r[i] && r[i] == 1) {
      key++;
    }
    if (b[i] == r[i] && r[i] == 1) {
      summ--;
    }
  }
  if (key == 0) {
    cout << -1;
  } else {
    summ = (summ / key) + 1;
    cout << summ;
  }
  return 0;
}
