#include <bits/stdc++.h>
using namespace std;
vector<int> test1or0(int n) {
  int x = 0;
  vector<int> robot;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 1) robot.push_back(i);
  }
  return robot;
}
int overlap(const vector<int>& vec1, const vector<int>& vec2) {
  unsigned long sr = vec1.size();
  unsigned long sb = vec2.size();
  int OL = 0;
  for (unsigned long i = 0; i < sr; i++) {
    int srElement = vec1[i];
    for (unsigned long j = 0; j < sb; j++) {
      if (srElement == vec2[j]) {
        OL += 1;
        break;
      }
    }
  }
  return OL;
}
int main() {
  int n;
  cin >> n;
  vector<int> roboco = test1or0(n);
  vector<int> bionic = test1or0(n);
  unsigned long sr = roboco.size();
  unsigned long sb = bionic.size();
  if (roboco.empty())
    cout << -1;
  else if (sr > sb)
    cout << 1;
  else {
    long OL = overlap(roboco, bionic);
    if (OL == 0)
      cout << sb / sr + 1;
    else if (OL == sr)
      cout << -1;
    else {
      int noOLsr = sr - OL;
      int noOLsb = sb - OL;
      cout << noOLsb / noOLsr + 1;
    }
  }
}
