#include #ifdef LOCAL #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; bool check(const vector &a) { bool ok = true; for (int i = 0; i < a.size() - 1; i++) ok &= a[i] < a[i + 1]; return ok; } int main() { int T; cin >> T; while (T--) { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++) cin >> A[i]; if (check(A)) { cout << 0 << '\n'; continue; } ll lo = -1, hi = 2e9; while (hi - lo > 1) { ll mid = (lo + hi) / 2; vector B(N); for (int i = 0; i < N; i++) B[i] = A[i] + mid * i; if (check(B)) { hi = mid; } else { lo = mid; } } if (lo == -1) { cout << -1 << '\n'; } else { cout << hi << '\n'; } } }