{"problem":{"name":"C. Large Summation","description":{"content":"You are given an array a consisting of n element a1, a2, ..., an. For each element ai you must find another element aj (i ≠ j), such that the summation of ai and aj mod (109 + 7) (i.e. (ai + aj) % (10","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10153C"},"statements":[{"statement_type":"Markdown","content":"You are given an array a consisting of n element a1, a2, ..., an. For each element ai you must find another element aj (i ≠ j), such that the summation of ai and aj mod (109 + 7) (i.e. (ai + aj) % (109 + 7)) is as maximal as possible. \n\nCan you help judges by solving this hard problem?\n\nThe first line contains an integer T, where T is the number of test cases.\n\nThe first line of each test contains an integer n (2 ≤ n ≤ 105), where n is the size of the array a.\n\nThe second line of each test case contains n integers a1, a2, ..., an (0 ≤ ai < 109 + 7), giving the array a.\n\nFor each test case, print a single line containing n space separated elements, such that the ith element is the answer to the ith element in the array a (i.e. the maximum value of (ai + aj) % (109 + 7)).\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 contains an integer n (2 ≤ n ≤ 105), where n is the size of the array a.The second line of each test case contains n integers a1, a2, ..., an (0 ≤ ai < 109 + 7), giving the array a.\n\n## Output\n\nFor each test case, print a single line containing n space separated elements, such that the ith element is the answer to the ith element in the array a (i.e. the maximum value of (ai + aj) % (109 + 7)).\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, with $ 2 \\leq n_k \\leq 10^5 $.  \n- Let $ A_k = (a_{k,1}, a_{k,2}, \\dots, a_{k,n_k}) $ be a sequence of integers where $ 0 \\leq a_{k,i} < 10^9 + 7 $.  \nLet $ M = 10^9 + 7 $.\n\n**Constraints**  \n1. $ 1 \\leq T \\leq \\text{large} $ (implied by constraints on $ n $)  \n2. For each $ k \\in \\{1, \\dots, T\\} $:  \n   - $ 2 \\leq n_k \\leq 10^5 $  \n   - $ 0 \\leq a_{k,i} < M $ for all $ i \\in \\{1, \\dots, n_k\\} $\n\n**Objective**  \nFor each test case $ k $, and for each element $ a_{k,i} $, compute:  \n$$\nb_{k,i} = \\max_{\\substack{j \\in \\{1, \\dots, n_k\\} \\\\ j \\neq i}} \\left( (a_{k,i} + a_{k,j}) \\bmod M \\right)\n$$  \nOutput the sequence $ (b_{k,1}, b_{k,2}, \\dots, b_{k,n_k}) $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10153C","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}