#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
int main() {
  int n;
  cin >> n;
  V<ll> A(n), B(n);
  priority_queue<pair<int, int>> p;
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> B[i];
    p.push({B[i], i + 1});
  }
  V<ll> circle(n + 2);
  circle[0] = B[n - 1];
  for (int i = 1; i <= n; i++) {
    circle[i] = B[i - 1];
  }
  circle[n + 1] = B[0];
  ll ans = 0;
  while (!p.empty()) {
    auto pi = p.top();
    p.pop();
    int i = pi.second;
    if (circle[i] - circle[i - 1] - circle[i + 1] >= A[i - 1]) {
      ans++;
      circle[i] -= (circle[i - 1] + circle[i + 1]);
      if (circle[i] > A[i - 1]) {
        p.push({circle[i], i});
      }
    } else {
      cout << -1 << endl;
      return 0;
    }
    if (i == 1) {
      circle[n + 1] = circle[1];
    }
    if (i == n) {
      circle[0] = circle[n];
    }
  }
  cout << ans << endl;
  return 0;
}
