Chef and new recipe

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Rupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A_{1}, A_{2}, ..., A_{N} respectively to store it. But as she is lazy to arrange them she puts them all in a storage box.
Chef comes up with a new recipe and decides to prepare it. He asks Rupsa to get two units of each type ingredient for the dish. But when she went to retrieve the ingredients, she realizes that she can only pick one item at a time from the box and can know its type only after she has picked it out. The picked item is not put back in the bag.
She, being lazy, wants to know the maximum number of times she would need to pick items from the box in the worst case so that it is guaranteed that she gets at least two units of each type of ingredient. If it is impossible to pick items in such a way, print 1.
Input
 The first line of the input contains an integer T denoting the number of test cases.
 The first line of each test case contains a single integer N denoting the number of different type of ingredients.
 The second line contains N spaceseparated integers A_{1}, A_{2}, ..., A_{N} denoting the quantity of each ingredient.
Output
 For each test case, output a single line containing an integer denoting the answer corresponding to that test case.
Constraints
 1 ≤ T ≤ 10
 1 ≤ N ≤ 10^{5}
 1 ≤ A_{i} ≤ 10^{4}
Sub tasks
 Subtask #1: 1 ≤ N ≤ 1000 (30 points)
 Subtask #2: original constraints (70 points)
Example
Input: 2 2 2 2 1 6 Output: 4 2
Explanation
 In Example 1, she need to pick up all items.
 In Example 2, since there is only one type of ingredient, picking two items is enough.
Author:  abhra73 
Tester:  kevinsogo 
Editorial  http://discuss.codechef.com/problems/CHEFRP 
Tags  abhra73, basicmath, cakewalk, may15 
Date Added:  3032015 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 