{"raw_statement":[{"iden":"statement","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"},{"iden":"input","content":"The 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."},{"iden":"output","content":"For 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))."},{"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, 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}) $.","simple_statement":"For each element in the array, find another different element such that their sum modulo (10^9 + 7) is as large as possible. Print the maximum sum modulo for each element.","has_page_source":false}