n = input()
A = map(int,raw_input().split()) #??°???????????????????????\??£?????°???
q = input()
B = map(int,raw_input().split()) #??????????????°????????\??£?????????


C = 0
for i in xrange(n):
 if B[0] > A[i]:
  C = C + A[i]
  if B[0] <  