T=int(raw_input())
for ti in range(T):
N=int(raw_input())
A=map(int,raw_input().split())
dpLeft=[[1000000001 for i in range(N+1)] for j in range(N)]
dpRight=[[1000000001 for i in range(N+1)] for j in range(N)]
for i,a in enumerate(A):
dpLeft[i][0]=0
for j in range(1,i+1):
# fill dpLeft[i][j]
for k in range(i):
if A[k] dpLeft[k][j-1]:
dpLeft[i][j]=min(dpLeft[i][j],A[i]-A[k])
A.reverse()
for i,a in enumerate(A):
dpRight[i][0]=0
for j in range(1,i+1):
# fill dpRight[i][j]
for k in range(i):
if A[k] dpRight[k][j-1]:
dpRight[i][j]=min(dpRight[i][j],A[i]-A[k])
ans=0
for i in range(N):
left=0
while left