def main(): n=int(input()) m1=int(input()) a=list(map(int,input().split())) m2=int(input()) b=list(map(int,input().split())) d=set() c = 0 for i in range(m1): c += a[i] d.add(c) c = n for i in range(m2): c -= b[i] d.add(c) ans = n - len(d) print(ans+1) if __name__ == "__main__": main()