n = int(input()) input() now = 0 st = {0, n} for x in map(int, input().split()): now += x st.add(now) assert now == n input() for x in map(int, input().split()): now -= x st.add(now) assert now == 0 ans = n + 1 - len(st) print(ans)