#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF 1000000001 int main() { int T; cin >> T; rep(i, T) { int N; cin >> N; vector A(N), B(N); int dif = INF; rep(j, N) { cin >> A[j]; if (j > 0) dif = min(A[j] - A[j-1], dif); } if (dif > 0) cout << 0 << endl; else cout << 1 - dif << endl; } return 0; }