|
||||||||||
FlowerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3517 Accepted Submission(s): 909 Problem Description Rabbit loves flowers very much and she plants n pots of flowers in her house. But she never prunes them because she is lazy. So the flowers have different heights and look ugly. One day, Kayaking decides to prune the flowers to make them look beautiful. To make them have equal heights, smart Kayaking has a wonderful idea. Initially, the i-th pot of flower’s height is a[i]. Each time, Kayaking will select n-1 pots of flowers and prune them to make their height subtract 1 with his 49m knife. Exactly, the height of the flowers is at least 1. Now, Kayaking wants to know if it is possible to prune the flowers to make them have equal height. If possible, what is the minimum times he prunes the flowers. Could you tell him? Input The input starts with a line contains exactly one positive number T which is the number of test case. Each test case starts with a line contains a number n indicates the number of flowers. Then there is a line contains n numbers indicates a[i]. Output For each test case, print a single line containing one integer—the minimum times Kayaking prunes the flowers, or -1 if it is impossible. Sample Input
Sample Output
Hint T<=10,n<=10^5,ai<=10^9 Source | ||||||||||
|