import sys input = sys.stdin.readline def main(): N = int(input()) M1 = int(input()) A = list(map(int, input().split())) M2 = int(input()) B = list(map(int, input().split())) At = [0] * (M1 + 1) for i in range(M1): At[i+1] = At[i] + A[i] Bt = [N] * (M2 + 1) for i in range(M2): Bt[i+1] = Bt[i] - B[i] ans = (N + 1) - len(set(At) | set(Bt)) print(ans)