Infinite Increments

All submissions for this problem are available.
Chef has a garden with $N$ plants arranged in a line in decreasing order of height. Initially the height of the plants are $A_1, A_2, ..., A_N$. The plants are growing, after each hour the height of the $i$th plant increases by $i$ millimeters. Find the minimum number of integer hours that Chef must wait to have two plants of the same height. ###Input:  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first line of each test case contains a single integer $N$.  The second line contains $N$ space separated integers $A_1,A_2,..A_N$. ###Output: For each test case print a single line containing one integer, the minimum number of integer hours that Chef must wait to have two plants of the same height. ###Constraints  $1 \leq T \leq 1000$  $2 \leq N \leq 10^5$  $0\leq A_i \leq 10^{18}$  $A_i >A_{i+1}$, for each valid $i$  The Sum of $N$ over all test cases does not exceed $10^6$ ###Sample Input: ``` 1 3 8 4 2 ``` ###Sample Output: ``` 2 ``` ###EXPLANATION: After $2$ hours there are two plants with the same height. $[8,4,2] \rightarrow [9,6,5] \rightarrow [10,8,8]$.Author:  hackslash_123 
Editorial  https://discuss.codechef.com/problems/INFTINCR 
Tags  cnmp2019, easy, hackslash_123, observations, taran_1407 
Date Added:  20082019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
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. 