5
1
100
2
100 1
2
1 2
3
1 100 2
3
1 2 3
3
1 5 6
3
1 7 8
3
8 7 1
3
7 8 1
3
7 1 8
0
0
0
1
0
for tc in range(input()):
	n = input()
	a = map(int,raw_input().split())
	k=ans=0
	if n < 3:
		ans=0
	else:
		t=abs(a[0]-a[1])
		k=t
		for i in range(1,n-1):
			t = abs(abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]) - abs(a[i-1]-a[i+1]))
			if t>k:
				k=t
				ans = i
	if n > 2 and abs(a[n-1]-a[n-2]) > k:
		ans = n-1
	print ans