#include <iostream>
using namespace std;
const int MAX_SIZE = 50000;
int main() {
int n, v[MAX_SIZE + 1];
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
int p = 2;
while (p) {
int x = v[n];
for (int i = n - 1; i >= 1; --i) {
v[i + 1] = v[i];
}
v[1] = x;
--p;
} /*
for (int i = 1; i <= n; ++i) {
cout << v[i] << " ";
} */
int k, currentNo;
cin >> k;
while (k) {
cin >> currentNo;
int left = 1, right = n, found = 0;
int middle = (left + right) / 2;
for (int i = 1; i <= n; ++i) {
if (v[i] <= v[middle] && v[i] == currentNo) {
cout << currentNo << " se gaseste in sir\n";
found = 1;
break;
}
if (v[middle] <= v[left] &&
v[i] == currentNo && !found) {
cout << currentNo << " se gaseste in sir\n";
found = 1;
}
}
if (!found) {
cout << currentNo << " nu se gaseste in sir\n";
}
--k;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gNTAwMDA7CgppbnQgbWFpbigpIHsKCWludCBuLCB2W01BWF9TSVpFICsgMV07CgljaW4gPj4gbjsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewoJCWNpbiA+PiB2W2ldOwoJfQoJaW50IHAgPSAyOwoJd2hpbGUgKHApIHsKCQlpbnQgeCA9IHZbbl07CgkJZm9yIChpbnQgaSA9IG4gLSAxOyBpID49IDE7IC0taSkgewoJCQl2W2kgKyAxXSA9IHZbaV07CgkJfQoJCXZbMV0gPSB4OwoJCS0tcDsKCX0gLyoKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewoJCWNvdXQgPDwgdltpXSA8PCAiICI7Cgl9ICovCglpbnQgaywgY3VycmVudE5vOwoJY2luID4+IGs7Cgl3aGlsZSAoaykgewoJCWNpbiA+PiBjdXJyZW50Tm87CgkJaW50IGxlZnQgPSAxLCByaWdodCA9IG4sIGZvdW5kID0gMDsKCQlpbnQgbWlk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