import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) n = int(input()) #alist = list(map(int,input().split())) #alist = [] #s = input() #n,m = map(int,input().split()) #for i in range(n): # alist.append(list(map(int,input().split()))) m = int(input()) alist = list(map(int,input().split())) m = int(input()) blist = list(map(int,input().split())) ans = set() temp = 0 ans.add(temp) for i in alist: temp += i ans.add(temp) for i in blist: temp -= i ans.add(temp) print(n+1-len(ans))