#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, int> pr;
int N;
long long A[200001], B[200001];
int getPrev(int x) { return (x - 1 + N) % N; }
int getNext(int x) { return (x + 1) % N; }
set<pr> tmp;
long long cnt = 0;
int main(void) {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    if (B[i] < A[i]) {
      cout << -1 << endl;
      return 0;
    }
    if (B[i] != A[i]) tmp.insert({B[i], i});
  }
  int lastId = N + 1;
  long long lastVal = 2e9 + 1;
  long long op = 0;
  while (tmp.size() > 0) {
    op++;
    if (op > 1e7) {
      cout << -1 << endl;
      return 0;
    }
    auto it = tmp.end();
    it--;
    int id = it->second;
    long long val = it->first;
    if (id == lastId && val == lastVal) {
      cout << -1 << endl;
      return 0;
    }
    lastId = id;
    lastVal = val;
    long long nxtval = A[id];
    tmp.erase(it);
    int prev = getPrev(id);
    int nxt = getNext(id);
    nxtval = max(nxtval, B[prev]);
    nxtval = max(nxtval, B[nxt]);
    long long incre = (B[id] - nxtval) / (B[prev] + B[nxt]);
    B[id] = (B[id] - nxtval) % (B[prev] + B[nxt]) + nxtval;
    if (B[id] > nxtval) {
      B[id] -= (B[prev] + B[nxt]);
      incre++;
    }
    if (incre == 0) {
      B[id] -= (B[prev] + B[nxt]);
      incre++;
    }
    cnt += incre;
    if (B[id] < A[id]) {
      cout << -1 << endl;
      return 0;
    }
    if (B[id] > A[id]) {
      tmp.insert({B[id], id});
    }
  }
  cout << cnt << endl;
  return 0;
}
