#C9925. Minimum Operations to One Chocolate

    ID: 54072 Type: Default 1000ms 256MiB

Minimum Operations to One Chocolate

Minimum Operations to One Chocolate

You are given T test cases. For each test case, there are N boxes, and each box contains a certain number of chocolates. In one operation, you can remove one chocolate from a box. Your goal is to make sure that each box contains at most one chocolate.

For a box containing \(a\) chocolates, you must perform \(a-1\) operations to reduce it to one chocolate. The total number of operations for a test case is the sum over all boxes, i.e.,

\[ \text{Total Operations} = \sum_{i=1}^{N} (a_i - 1) \]

Read the input from standard input and write the answer for each test case on a separate line to standard output.

inputFormat

The first line of the input contains a single integer T, the number of test cases. Each test case consists of two lines:

  1. The first line contains an integer N, the number of boxes.
  2. The second line contains N space-separated integers representing the number of chocolates in each box.

outputFormat

For each test case, output a single integer representing the minimum number of operations required, with each answer printed on a new line.## sample

3
4
3 4 5 6
2
7 10
3
1 2 3
14

15 3

</p>