← Home
write a go solution for A. Submission is All You Needtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFor a multiset T consisting of non-negative integers, we define:  sum(T) is the sum of all elements in T. For example, if T=0,1,1,3, then sum(T)=0+1+1+3=5.  mex(T) is the smallest non-negative integer not in T. For example, if T=0,1,1,3, then mex(T)=2 because 2 is the smallest non-negative integer not present in T. You are given a multiset S of size n consisting of non-negative integers. At first, your score is 0. You can perform the following operations any number of times in any order (possibly zero):  Select a subset S'subseteqS (i.e., S' contains some of the elements currently in S), add sum(S') to your score, and then remove S' from S.  Select a subset S'subseteqS, add mex(S') to your score, and then remove S' from S. Find the maximum possible score that can be obtained.InputEach test contains multiple test cases. The first line contains the number of test cases t (1<=t<=10^3). The description of the test cases follows. The first line of each test case contains a single integer n (1<=n<=50).The second line of each test case contains n integers S_1,S_2,ldots,S_n (0<=S_i<=50).OutputFor each test case, print a single integer — the maximum possible score that can be obtained.ExampleInput230 1 131 2 3Output3
6
NoteIn the first test case, a possible optimal strategy is as follows:  Select S'=0,1, add mex(S')=mex(0,1)=2 to your score, and then remove S' from S. Currently, your score is 2 and S=1.  Select S'=1, add sum(S')=sum(1)=1 to your score, and then remove S' from S. Currently, your score is 3 and S=varnothing. After that, you cannot do any further operations. It can be proven that 3 is the maximum possible score that can be obtained.. Output only the code with no comments, explanation, or additional text.