n = int(input())
a = [0] + sorted(list(map(int, input().split())))
q = int(input())
for _ in range(q):
x = int(input())
l = 0; r = n; kq = 0
while l <= r:
m = (l + r) // 2
if x > a[m]:
l = m + 1
kq = m
else: r = m - 1
print(kq)
biA9IGludChpbnB1dCgpKQphID0gWzBdICsgc29ydGVkKGxpc3QobWFwKGludCwgaW5wdXQoKS5zcGxpdCgpKSkpCnEgPSBpbnQoaW5wdXQoKSkKZm9yIF8gaW4gcmFuZ2UocSk6CiAgICB4ID0gaW50KGlucHV0KCkpCiAgICBsID0gMDsgciA9IG47IGtxID0gMAogICAgd2hpbGUgbCA8PSByOgogICAgICAgIG0gPSAobCArIHIpIC8vIDIKICAgICAgICBpZiB4ID4gYVttXToKICAgICAgICAgICAgbCA9IG0gKyAxCiAgICAgICAgICAgIGtxID0gbQogICAgICAgIGVsc2U6IHIgPSBtIC0gMQogICAgcHJpbnQoa3EpCg==