from collections import * t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) d = defaultdict(int) for i in range(n): d[i] = a[i] # 初期座標 ans = 0 for i in range(n-1): if d[i] < d[i+1]: continue num = d[i] - d[i+1] + 1 ans = max(ans,num) print(ans)