#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
#define N 201000
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-') flag = true; c = getchar(); }
	while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar();
	if (flag)	x = -x;
}
using namespace std;
int n;
int a[N], b[N], h[N], htot;
long long ans;
inline void sol(int L, int R) {
	if (L + 1 == R)	return ;
//	printf("sol(%d, %d) : \n", L, R);
	int ptr = R;
	for (int i = L + 1; i < R; ++i) if (b[i] > a[i]) { ptr = i; break; }
//	printf("ptr = %d\n", ptr);
	int tol = a[ptr - 1];
	for (int i = ptr - 1; i > L; --i) {
		if (b[i] < tol) {
			int p = upper_bound(a + L, a + R + 1, b[i]) - a - 1;//bug
//			printf("i = %d, p = %d\n", i, p);
			ans += i - p;
			tol = b[i];
		}
	}
	int tor = a[ptr];
	for (int i = ptr; i < R; ++i) {
		if (b[i] > tor) {
			int p = lower_bound(a + L, a + R + 1, b[i]) - a;//bug bug
//			printf("i = %d, p = %d\n", i, p);
			ans += p - i;
			tor = b[i];
		}
	}
}
int main() {
	read(n);
	int L;
	read(L);
	++n; ++n;
	a[0] = b[0] = 0; a[n - 1] = b[n - 1] = L + 2 - n;//0 ... L + 1
	for (int i = 1; i < n - 1; ++i) read(a[i]), a[i] -= i;
	for (int i = 1; i < n - 1; ++i) read(b[i]), b[i] -= i;
//	for (int i = 0; i < n; ++i) printf("%d ", a[i]); puts("");
//	for (int i = 0; i < n; ++i) printf("%d ", b[i]); puts("");
	for (int i = 0; i < n; ++i) h[++htot] = a[i];
	htot = unique(h + 1, h + 1 + htot) - h - 1; h[htot + 1] = -12341;
	for (int i = 0; i < n; ++i) a[i] = lower_bound(h + 1, h + 1 + htot, a[i]) - h;
	for (int i = 0; i < n; ++i) {
		int v = lower_bound(h + 1, h + 1 + htot, b[i]) - h;
		if (h[v] != b[i]) return puts("-1"), 0;
		b[i] = v;
	}
//	for (int i = 0; i < n; ++i) printf("%d ", a[i]); puts("");
//	for (int i = 0; i < n; ++i) printf("%d ", b[i]); puts("");
	int lst = 0;
	for (int i = 1; i < n; ++i) if (a[i] == b[i]) {
//		printf("\ni = %d : \n", i);
		sol(lst, i); lst = i;
//		printf("ans = %lld\n", ans);
	}
	printf("%lld\n", ans);
	return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

using namespace std;

int n,q;
ll a[100010],c[100010];
ll k;

int main(){
    cin >> n >> q;
    rep(i,n){
        cin >> a[i];
    }
    sort(a, a+n);
    rep(i,n){
        c[i] = a[i]-i-1;
    }

    rep(ii,q){
        cin >> k;
        int ldx = lower_bound(c, c+n, k)-c;
        if(ldx >= 0 && ldx < n && c[ldx] == k){
            cout << a[ldx]-1 << endl;
            continue;
        }

        int idx = upper_bound(c, c+n, k)-c-1;
        // cout << "ii " << ii << " idx "  << idx <<endl;
        if(idx == -1){
            cout << k << endl;
        }
        else {
            cout << a[idx]+k-c[idx]<<endl;
        }
    }

}