import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int t = sc.nextInt(); String result = IntStream.range(0, t).mapToObj(a -> { int n = sc.nextInt(); int[] values = new int[n + 1]; for (int i = 1; i <= n; i++) { values[i] = sc.nextInt(); } boolean first = true; for (int i = 1; i < n && first; i++) { first = values[i] < values[i + 1]; } if (first) { return "0"; } long left = 0; long right = Integer.MAX_VALUE; while (right - left > 1) { long m = (left + right) / 2; boolean disable = false; for (int i = 1; i < n && !disable; i++) { disable = values[i] + i * m >= values[i + 1] + (i + 1) * m; } if (disable) { left = m; } else { right = m; } } boolean enable = true; for (int i = 1; i < n && enable; i++) { enable = values[i] + i * right < values[i + 1] + (i + 1) * right; } return String.valueOf(enable ? right : -1); }).collect(Collectors.joining("\n")); System.out.println(result); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }