T = int(input()) for _ in range(T): A = list(map(int,input().split())) ans = 0 for i in range(len(A) - 1): a = A[i] b = A[i + 1] if b <= a: ans = max(ans,a - b + 1) print(ans)