for _ in range(int(input())): N = int(input()) A = list(map(int, input().split())) print(max(0, max(A[i] - A[i + 1] + 1 for i in range(N - 1))))