You are given an array $$A$$ that consists of $$N$$ elements.
Assume that a function \(F(x) = (x\:mod\:A_1) + (x\:mod\:A_2)\:+\: ..... \:+\:(x\:mod\:A_N)\), for some non-negative integer $$x$$. You are required to find the maximum possible value of the function $$F(x)$$.
Here, \(X\:mod\:Y\) denotes the remainder of the $$X$$ division by $$Y$$.
Input format
- The first line contains an integer $$T$$ denoting the number of test cases.
- The first line of each test case contains an integer $$N$$ denoting the size of array $$A$$.
- The second line of each test case contains $$N$$ space-separated integers denoting array $$A$$.
Output format
For each test case, print the maximum possible value of $$F(x)$$ in a new line.
Constraints
It is guaranteed that the sum of $$N$$ over $$T$$ test cases does not exceed $$1e6$$.
For the first testcase, we can take x = 9599. Thus, the maximum possible value of F(x) is 26.
For the second testcase, we can take x = 159. Thus, the maximum possible value of F(x) is 14.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor