#pragma GCC target("avx2") #pragma GCC optimize("Ofast,unroll-loops") #include #include #define rep(i, n) for (int i = 0; i < n; i++) #define per(i, n) for (int i = n - 1; i >= 0; i--) #define ALL(a) a.begin(), a.end() typedef long double ldouble; #undef long #define long long long #define ll long #define vec vector using namespace std; using mint = atcoder::modint; ostream &operator<<(ostream &os, mint a) { return os << a.val(); } template ostream &operator<<(ostream &os, vector &a) { const int n = a.size(); rep(i, n) { os << a[i]; if (i + 1 != n) os << " "; } return os; } template ostream &operator<<(ostream &os, array &a) { rep(i, n) os << a[i] << " \n"[i + 1 == n]; return os; } template istream &operator>>(istream &is, vector &a) { for (T &i : a) is >> i; return is; } template bool chmin(T &x, T y) { if (x > y) { x = y; return true; } return false; } template bool chmax(T &x, T y) { if (x < y) { x = y; return true; } return false; } void solve() { int n; cin >> n; vec a(n); cin >> a; long ans = 0; for (int i = 1; i < n; i++) chmax(ans, a[i - 1] - a[i] + 1); cout << ans << '\n'; } int main() { // srand((unsigned)time(NULL)); cin.tie(nullptr); ios::sync_with_stdio(false); // cout << fixed << setprecision(400); int t = 1; cin >> t; while (t--) solve(); return 0; }