#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double Pi = acos(-1);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
double dpow(double a, long long b) {
  double ans = 1.0;
  while (b) {
    if (b % 2) ans = ans * a;
    a = a * a;
    b /= 2;
  }
  return ans;
}
long long quick_pow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) {
      ans = ans * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
int a[maxn];
int b[maxn];
int n;
bool check() {
  for (int i = 1; i <= n; i++) {
    if (a[i] == 1 && b[i] == 0) return true;
  }
  return false;
}
int main() {
  scanf("%d", &n);
  int suma = 0, sumb = 0;
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i]) flag = 1;
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (a[i] && !b[i]) suma++;
    if (!a[i] && b[i]) sumb++;
  }
  if (flag == 0) {
    printf("-1\n");
    return 0;
  }
  if (!check()) {
    printf("-1\n");
    return 0;
  }
  int cnt1 = 0;
  int cnt2 = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] && !b[i]) cnt1++;
    if (!a[i] && b[i]) cnt2++;
  }
  cout << (cnt2 + cnt1) / cnt1 << endl;
  return 0;
}
