{"problem":{"name":"G. Magical Indices","description":{"content":"Alaa sometimes feels bored at work, so at such times she starts playing with a beautiful array a consisting of n integers a1, a2, ..., an. Alaa starts counting the number of magical indices in the ar","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10153G"},"statements":[{"statement_type":"Markdown","content":"Alaa sometimes feels bored at work, so at such times she starts playing with a beautiful array a consisting of n integers a1, a2, ..., an.\n\nAlaa starts counting the number of magical indices in the array a. An index x is said to be magical if it satisfying the following rules: \n\nCan you help Alaa by counting the number of magical indices in the array a.\n\nThe first line contains an integer T, where T is the number of test cases.\n\nThe first line of each test case contains an integer n (1 ≤ n ≤ 106), where n is the size of the array a.\n\nThe second line of each test case contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106), giving the array a.\n\nFor each test case, print a single line containing the number of magical indices in the array a.\n\nAs input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use _scanf/printf_ instead of _cin/cout_ in C++, prefer to use _BufferedReader/PrintWriter_ instead of _Scanner/System.out_ in Java.\n\n## Input\n\nThe first line contains an integer T, where T is the number of test cases.The first line of each test case contains an integer n (1 ≤ n ≤ 106), where n is the size of the array a.The second line of each test case contains n integers a1, a2, ..., an (1 ≤ ai ≤ 106), giving the array a.\n\n## Output\n\nFor each test case, print a single line containing the number of magical indices in the array a.\n\n[samples]\n\n## Note\n\nAs input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use _scanf/printf_ instead of _cin/cout_ in C++, prefer to use _BufferedReader/PrintWriter_ instead of _Scanner/System.out_ in Java.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ n_k \\in \\mathbb{Z} $ denote the size of the array.  \n- Let $ A_k = (a_{k,1}, a_{k,2}, \\dots, a_{k,n_k}) $ be the array of integers.  \n\n**Constraints**  \n1. $ 1 \\le T \\le 10^5 $  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 1 \\le n_k \\le 10^6 $  \n   - $ 1 \\le a_{k,i} \\le 10^6 $ for all $ i \\in \\{1, \\dots, n_k\\} $  \n\n**Objective**  \nFor each test case $ k $, count the number of indices $ x \\in \\{1, \\dots, n_k\\} $ such that:  \n$$\na_{k,x} = \\sum_{\\substack{j=1 \\\\ j \\ne x}}^{n_k} a_{k,j}\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10153G","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}