#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7;
ll n;
vector<ll> lst;
inline vector<ll> Amount(ll x){
ll returner=1;
while(x%2==0){
x/=2;
returner*=2;
}
return {x,returner};
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
lst.resize(n+1);
for(ll i=1;i<=n;i++){
cin >> lst[i];
}
vector<pair<ll,ll>> PosLst;
ll CurrPos=1;
for(ll i=1;i<=n;i++){
ll num=lst[i];
vector<ll> Info=Amount(num);
ll FinalNum=Info[0];
ll Amount=Info[1];
PosLst.push_back({CurrPos,FinalNum});
CurrPos+=Amount;
}
ll q;
cin >> q;
for(auto i:PosLst){
//cout << i.first << " " << i.second << "\n";
}
//cout << "----------" << "\n";
while(q--){
ll pos;
cin >> pos;
auto itr=lower_bound(PosLst.begin(),PosLst.end(),pos,[](const pair<ll,ll>& elements, ll target){
return elements.first<target;
});
//cout << "Query: "<< pos << " " << (*itr).first << ": \n";
if((*itr).first>pos or itr==PosLst.end()){
itr--;
}
cout << (*itr).second << "\n";
}
}