using System.Linq; using System; public class Hello { static void Main() { var n = int.Parse(Console.ReadLine().Trim()); var an = int.Parse(Console.ReadLine().Trim()); string[] line = Console.ReadLine().Trim().Split(' '); var a = Array.ConvertAll(line, int.Parse); var bn = int.Parse(Console.ReadLine().Trim()); line = Console.ReadLine().Trim().Split(' '); var b = Array.ConvertAll(line, int.Parse); getAns(n, an, a, bn, b); } static void calc(int n, int aL, int[] a, bool[] c) { var p = 0; c[p] = true; for (int i = 0; i < aL; i++) { p += a[i]; c[p] = true; } } static void getAns(int n, int an, int[] a, int bn, int[] b) { var c = new bool[n + 1]; calc(n, an, a, c); Array.Reverse(b); calc(n, bn, b, c); var ans = c.Count(x => x == false); Console.WriteLine(ans); } }