#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; void solve() { int N; cin >> N; vector A(N + 1); for (int i = 1; i <= N; i++) cin >> A[i]; ll ans = 0; for (int i = 1; i <= N - 1; i++) { if (A[i] >= A[i + 1]) { ans = max(ans, A[i] - A[i + 1] + 1); } } cout << ans << endl; } int main() { int T; cin >> T; while (T--) { solve(); } return 0; }