In 20XX, the owners of the ICPC (Ikuta's Computer Pollutes Community) shopping district were suffering from air pollution. In order to regain the vitality of the past, the cleanliness of the atmosphere must be kept above a certain level.

The shops in the shopping district are lined up in a row and are numbered from 1 to n. Currently, the cleanliness of the atmosphere around each store is pi. You can change the cleanliness of the atmosphere in that store and the surrounding stores by choosing the 2nd to n-1st stores and circulating the air around them. To be precise, when the i (2 ≤ i ≤ n−1) th is selected, only pi is added to pi−1 and pi + 1, and conversely, only 2 pi is subtracted from pi. In other words, the new cleanliness of the atmosphere p'is,

* p'i−1 = pi−1 + pi
* p'i = pi − 2 pi
* p'i + 1 = pi + 1 + pi. The purpose is to repeat this operation to make the air cleanliness pi of all stores equal to or greater than the minimum acceptable air cleanliness li.



It costs a lot to circulate the atmosphere, so we want to achieve it as few times as possible. I want you to help us for the future of the ICPC shopping district.



Input

The input is given in the following format.


n
p1 ... pn
l1 ... ln


n is the number of stores, pi is the current clean air of the i-th store, and li is the clean air that the i-th store should achieve.

Constraints

Each variable being input satisfies the following constraints.

* 3 ≤ n ≤ 105
* −108 ≤ pi ≤ 108
* 1 ≤ li ≤ 108

Output

Output the minimum number of air circulations required by all stores to achieve clean air in one line.

If you cannot achieve it no matter how you operate it, output -1.

Examples

Input

3
3 -1 4
2 1 3


Output

1


Input

3
3 -1 4
2 1 5


Output

-1


Input

4
3 -1 -1 3
1 1 1 1


Output

3
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int n;
ll a[100005],b[100005];
vector<ll>vec;
ll bit[100005];
int f(int x){
	return x&-x;
}
void add(int i,int x){
	for(int s=i;s<100005;s+=f(s)) bit[s]+=x;
}
int sum(int i){
	int res=0;
	for(int s=i;s>0;s-=f(s)) res+=bit[s];
	return res;
}
void cnt(vector<int>vvec){
    reverse(vvec.begin(),vvec.end());
	ll ret = 0;
	for(int i=0;i<vvec.size();i++){
		ret += sum(vvec[i]);
		add(vvec[i],1);
	}
	printf("%lld\n",ret);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		a[i] += (i?a[i-1]:0LL); vec.pb(a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&b[i]);
		b[i] += (i?b[i-1]:0LL);
	}
	sort(vec.begin(),vec.end());
	for(int i=0;i<n;i++){
		if(b[i]-(i?b[i-1]:0LL) > vec[i]-(i?vec[i-1]:0LL)){
			puts("-1"); return 0;
		}
	}
	vector<int>c;
	for(int i=0;i<n;i++){
		c.pb(1 + lower_bound(vec.begin(),vec.end(),a[i])-vec.begin());
	}
	cnt(c);
}