#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<queue>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct solver_abc_037_c {
	int N;
	// ll ring_access(std::vector<ll> &vec, int i) {
	// 	return vec[i%N];
	// }
	bool lmax(std::vector<ll> &vec, int i) {
		// assume i is legal
		return (vec[(i+N-1) % N] < vec[i]) && (vec[i] > vec[(i+1)%N]);
	}
	ll dsum(std::vector<ll> &vec, int i) {
		// assume i is legal
		return (vec[(i+N-1) % N] + vec[(i+1)%N]);
	}
	ll dmax(std::vector<ll> &vec, int i) {
		// assume i is legal
		return std::max(vec[(i+N-1) % N], vec[(i+1)%N]);
	}
	ll backward(std::vector<ll> &vec, int i) {
		// assume i is legal
		return vec[i] - vec[(i+N-1) % N] - vec[(i+1)%N];
	}
	bool is_same(std::vector<ll> &A, std::vector<ll> &B) {
		for(int i = 0; i < N; ++i) {
			if(A[i] != B[i])
				return false;
		}
		return true;
	}

	ll run(int _N, std::vector<ll> A, std::vector<ll> B) {
		N = _N;
		ll cnt = 0, back;
		int not_same = 0;
		std::vector<ll> reduced = B;
		bool flag = false;
		auto c = [&](int l, int r) { return reduced[l] <= reduced[r]; };
		std::priority_queue<int, std::vector<int>, decltype(c)> que(c);
		for(int i = 0; i < N; ++i) {
			if(A[i] != B[i]) {
				que.push(i);
				not_same++;
			}
		}
		if(que.empty()) {
			return 0;
		}
		while(true) {
			// for(int i = 0; i < N; ++i) {
			// 	std::cerr << reduced[i] << " ";
			// }
			// std::cerr << std::endl;
			//for(int i = 0; i < N; ++i) {
			while(! que.empty()) {
				int i = que.top();
				que.pop();
				// std::cerr << "pop: " << i << std::endl;
				
				// for(int i = 0; i < N; ++i) {
				// 	std::cerr << reduced[i] << " ";
				// }
				// std::cerr << std::endl;
				while(true) {
					if(A[i] < reduced[i]) {
						// std::cerr << "found: " << i << std::endl;
						// not same
						if(lmax(reduced, i)) {
							ll sum_tonari = dsum(reduced, i);
							ll max_tonari = dmax(reduced, i);
							ll available = (reduced[i] - max_tonari)/sum_tonari + 1;
							ll have_to = std::max((reduced[i] - A[i])/sum_tonari, 1ll);
							if(available < have_to) {
								// std::cerr << "ret" << std::endl;
								return -1;
							}else{
								cnt += have_to;
								reduced[i] -= sum_tonari * have_to;
								flag = true;
								if(A[i] == reduced[i]) {
									not_same--;
								}
							}
							// // reduce local max
							// back = backward(reduced, i);
							// // std::cerr << "to: " << back << std::endl;
							// ll 
							// if(A[i] > back) {
							// 	return -1;
							// }else{
							// 	reduced[i] = back;
							// 	flag = true;
							// 	++cnt;
							// 	if(A[i] == reduced[i]) {
							// 		not_same--;
							// 	}
							// }

						}else{
							break;
						}
					}else{
						break;
					}
				}
				if(flag) {
					que.push(i);
					// que.push((i-1)%N);
					// que.push((i+1)%N);
					flag = false;
				}
			}
			if(not_same == 0) {
				return cnt;
			}
			if(flag == false) {
				return -1;
			}
			flag = false;
		}
		return -1;
	}
};

int main(void) {
	solver_abc_037_c solver;
	int N;
	std::vector<ll> A, B;
	ll t;

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> t;
		A.push_back(t);
	}
	for(int i = 0; i < N; ++i) {
		std::cin >> t;
		B.push_back(t);
	}

    std::cout << solver.run(N, A, B) << std::endl;

	return 0;
}


Measured memory_bytes: 11888