using System; using System.IO; using System.Collections; namespace test1 { class Program { static Hashtable table = new Hashtable(); static StreamReader streamReader = new StreamReader("..//..//problem.in"); static StreamWriter streamWriter = new StreamWriter("..//..//problem.out"); static int n = int.Parse(streamReader.ReadLine()); static void Main(string[] args) { // Program.exe runs from [your_source_code_location]\bin\Debug // So problem.in and problem.out in near your source code try{ Program3(); } finally { streamReader.Close(); streamWriter.Close(); } } static void Program3() { for (int i = 0; i < n; i++) { streamReader.ReadLine(); string line = streamReader.ReadLine(); string[] numbers = line.Split(' '); for (int t = 0; t < numbers.Length; t++) { addNewSums(t, numbers); } streamWriter.WriteLine(table.Count); table.Clear(); } } private static void addNewSums(int m, string[] numbers) { for (int i = m; i < numbers.Length; i++) { int sum = 0; for (int j = m ; j <= i; j++) { sum += int.Parse(numbers[j]); } if (!table.ContainsKey(sum)) { table.Add(sum, "1"); } } } } }