{"raw_statement":[{"iden":"statement","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"},{"iden":"input","content":"The 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."},{"iden":"output","content":"For each test case, print a single line containing the number of magical indices in the array a."},{"iden":"note","content":"As 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."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**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$$","simple_statement":"Count how many indices in the array are magical.  \nAn index x is magical if a[x] equals the number of times a[x] appears in the array.","has_page_source":false}