#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll mod = 1000000007;
class Debug {
 public:
  void debug(ll x) { cout << x << "\n"; }
  void debug(char x) { cout << x << "\n"; }
  void debug(ll a[], ll n) {
    for (ll i = 0; i < n; ++i) cout << a[i] << " ";
    cout << "\n";
  }
  void debug(vector<ll> a, ll n) {
    for (ll i = 0; i < n; ++i) cout << a[i] << " ";
    cout << "\n";
  }
  void debug(map<ll, ll> a) {
    for (auto it = a.begin(); it != a.end(); it++)
      cout << it->first << " " << it->second << "\n";
  }
  void debug(set<ll> second) {
    for (auto it = second.begin(); it != second.end(); it++) cout << *it << " ";
    cout << "\n";
  }
};
int main() {
  Debug D;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    ll n;
    cin >> n;
    ll a[n];
    ll b[n];
    for (ll i = 0; i < n; cin >> a[i++])
      ;
    for (ll i = 0; i < n; cin >> b[i++])
      ;
    ll flag = 0;
    for (ll i = 0; i < n; ++i) {
      if (a[i] == 1 && b[i] == 0) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      cout << -1 << "\n";
      return 0;
    }
    ll cnt = 0, cnt2 = 0;
    for (ll i = 0; i < n; ++i) {
      if (a[i] == 1 && b[i] == 0) {
        cnt++;
      }
      if (a[i] == 0 && b[i] == 1) {
        cnt2++;
      }
    }
    if (cnt2 % cnt == 0) {
      cout << cnt2 / cnt + 1 << "\n";
    } else
      cout << cnt2 / cnt + 1 << "\n";
  }
  return 0;
}
