Candy Distribution 2
Practice
1.9 (9 votes)
Combinatorics
Pigeonhole principle
Approved
Easy
Mathematics
Open
Probability and statistics
Problem
48% Success 5136 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

It is Jawa's birthday today. His each friend tells him the least number of toffees he wants. Later, his friends together decided that if he is able to satisfy the condition of atleast one of his friends than they will buy him a $1000 gift.
You have to help Jawa to decide the minimum number of toffees he need to buy to satisfy his friends conditions. This minimum number of toffees in any possible distribution should satisfy his friends condition.

Input:
First line contains a single integer T denoting number of test cases.
First line of each test case contains a single integer N denoting number of his friends.
Second line of each test case contains N space separated integers denoting the least number of toffees his each friend want.

Output:
For each test case output single integer denoting minimum number of toffees he needs to buy to satisfy the condition.

Constraints:
1<=T<=10
1<=N<=100000
1<=Ai<=1000000000

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
No similar problems found