n=int(input()) a=list(map(int,input().split())) Q=int(input()) x=list(map(int,input().split()))+[0] s=[] for i in range(Q+1): if i==0 or x[s[-1]]>x[i]: s+=[i] g=[0]*(Q+1) for v in a: now=0 while now1: m=(ok+ng)//2 if x[s[m]]<=v: ok=m else: ng=m g[now]+=v g[s[ok]]-=v now=s[ok] if now