n=int(input()) a=int(input()) A=list(map(int,input().split())) b=int(input()) B=list(map(int,input().split())) L=[1]*(n+1) tmp=0 for i in range(a): tmp+=A[i] L[tmp]=0 for i in range(b): tmp-=B[i] L[tmp]=0 print(sum(L))