#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long a[N], b[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) cin >> b[i];
  long long l = 0, h = 1e15;
  while (l <= h) {
    long long mid = (l + h) / 2;
    long long cnta = 0, cntb = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 1) {
        if (b[i] != 1) {
          cnta += mid;
        }
      } else {
        if (b[i] == 1) {
          cntb++;
        }
      }
    }
    if (cnta <= cntb)
      l = mid + 1;
    else
      h = mid - 1;
  }
  if (l == (1e15 + 1))
    cout << -1;
  else
    cout << l;
}
