/*input

*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <iomanip>
#include <climits>
#define mod 1000000007

// templates
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define po(x,y)   fixed<<setprecision(y)<<x
#define ss(s) scanf(" %[^\n]%*c", s)
#define ps(s) printf("%s\n",s)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;

void nl() {printf("\n");}
void sc(int&n) {int number; scanf("%d", &number); n = number;}
void sc(ll&n) {ll number; scanf("%lld", &number); n = number;}
void _print(ll t) {printf("%lld ", t);}
void _print(int t) {printf("%d ", t);}
void _print(string t) {cout << t;}
void _print(char t) {printf("%c\n", t);}
void _print(lld t) {cout << t;}
void _print(double t) {cout << t;}
void _print(ull t) {cout << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cout << "{"; _print(p.F); cout << ","; _print(p.S); cout << "}";}
template <class T> void _print(vector <T> v) {cout << "vec->[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(set <T> v) {cout << "set->[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(multiset <T> v) {cout << "multiset->[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T, class V> void _print(map <T, V> v) {cout << "map->[ "; for (auto i : v) {_print(i); cout << " ";} cout << "]";}

const ll inf = (ll)2e18 + 10;
const int N = (int)1e6 + 10;
bool possible(vector<ll>&a, ll val, ll k) {
	int n = sz(a);
	int l = 0, r = n - 1, ind = -1;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (a[mid] <= val) {
			ind = mid;
			l = mid + 1;
		}
		else {
			r = mid - 1;
		}
	}
	ll rem = (val - (ind + 1));
	if (rem >= k)return true;
	return false;
}
void solve()
{
	int n, q;
	sc(n), sc(q);
	std::vector<ll>a(n);

	for (int i = 0; i < n; ++i)
	{
		sc(a[i]);
	}
	while (q--) {
		ll k;
		sc(k);
		ll l = 1, r = inf, ans = -1;
		while (l <= r) {
			ll mid = (l + r) / 2;
			if (possible(a, mid, k)) {
				ans = mid;
				r = mid - 1;
			}
			else {
				l = mid + 1;
			}
		}
		_print(ans);
		nl();
	}
}

int main()
{
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
	int t = 1;
	// sc(t);
	while (t--) {
		solve();
	}
	return 0;

}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll x, y, a, b;
    cin >> x >> y >> a >> b;
    ll exp = 0;
    while (x * (a - 1) < b) {
        if (x >= LONG_LONG_MAX / a) {
            break;
        }
        x *= a;
        if (x >= y) {
            cout << exp << endl;
            return 0;
        }
        exp++;
    }
    exp += (y - x - 1) / b;
    cout << exp << endl;
}
