N = int(input()) M1 = int(input()) A = list(map(int, input().split())) M2 = int(input()) B = list(map(int, input().split())) s = set() a = 0 for i in range(M1): a += A[i] s.add(a) for i in range(M2): a -= B[i] s.add(a) # print(s) print(N - len(s) + 1)