#include <bits/stdc++.h>
using namespace std;

int main(){
    long double X, Y, R;
    cin >> X >> Y >> R;

    X = abs(X) + abs(ceil(R));
    Y = abs(Y) + abs(ceil(R));

    long long answer = 0;
    for(long long x = ceil(X - R); x <= X + R; ++x){
        long double dx = abs(X - x);
        long double dy = sqrt(R * R - dx * dx);
        long long y1 = floor(Y + dy);
        long long y2 = ceil(Y - dy);
        answer += (y1 - y2 + 1);
    }

    cout << answer;

    return 0;
}
#include<bits/stdc++.h>
#define For(a,b,c) for(int a=b;a<=c;++a)
#define Dor(a,b,c) for(int a=b;a>=c;--a)
#define CC(_...) fprintf(stderr,_)
using namespace std;
typedef long long LL;
enum{N=200007};
int n,A[N],C[N];
map<int,vector<int> > G;
void upd(int u,int k=-1) {
	for(;u<=n;u+=u&-u) C[u]+=k;
}
int sum(int u) {
	int r=0;
	for(;u;u&=u-1) r+=C[u];
	return r;
}
int main() {
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&A[i]),upd(i,1);
	Dor(i,n,1) G[A[i]+i].push_back(i);
	LL ans=0;
	For(i,1,n) {
		int x;
		scanf("%d",&x);
		if(G[x+i].empty()) puts("-1"),exit(0);
		ans+=sum(G[x+i].back())-1;
		upd(G[x+i].back()),G[x+i].pop_back();
	}
	cout<<ans;
	return 0;
}