The enmity between Logan and Donald Pierce  never ceases to exist.  
However, once Logan and Donald came face to face. Donald got agitated and asked Logan to prove his true mettle by solving a puzzle.   
Logan is provided an array Arr[] of  N  integers. He can select only a single integer from the array and can perform certain special operations on it any number of time.
An operation can be one of the following type : 
Decrement the integer by 1 provided that it is greater than 0
Increment the integer by 1

Donald asks Logan to tell the least number of operations required to obtain the smallest possible XOR sum of all the integers.
Since Logan is currently in hurry to meet Charles and Canibal, he asks you guys to solve this problem. Help him!! 
 
------ Input ------ 

First line contains an integer T denoting number of test cases. 
First line of each test case contains an integer N.
Second line of each test case contains N space separated integers
 
------ Output ------ 

For each test case, print an integer denoting the minimum number of required operations on a separate line.
 
------ Constraints ------ 

$1 ≤ T ≤ 10$
$1 ≤ N ≤ 10^{5}$
$0 ≤ Arr[i] ≤ 4294967296$
 
----- Sample Input 1 ------ 
1
4
1 1 1 1
----- Sample Output 1 ------ 
0
----- explanation 1 ------ 
Since the XOR sum of all numbers is 0 and can't be reduced further, the answer is 0.

Difficulty: MEDIUM_HARD

Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	xor = 0
	for i in range(n):
		xor = xor ^ L[i]
	ans = 10 ** 18 + 7
	for i in range(n):
		a = L[i]
		b = a ^ xor
		ans = min(abs(a - b), ans)
	print(ans)


import sys
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	xor = 0
	for i in range(n):
		xor = xor ^ a[i]
	if xor == 0:
		print(0)
		continue
	ans = sys.maxsize
	for i in range(n):
		ans = min(ans, abs(a[i] - (xor ^ a[i])))
	print(ans)


import sys
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	xor = 0
	for i in range(n):
		xor = xor ^ a[i]
	if xor == 0:
		print(0)
		continue
	ans = pow(10, 15)
	for i in range(n):
		ans = min(ans, abs(a[i] - (xor ^ a[i])))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	xor = 0
	for i in l:
		xor = xor ^ i
	mini = 100000000000
	for i in l:
		temp = i ^ xor
		if abs(temp - i) < mini:
			mini = abs(temp - i)
	print(mini)


import functools
import operator
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	sum_a = functools.reduce(operator.xor, a)
	if sum_a == 0:
		answer = 0
	else:
		answer = min([abs((sum_a ^ a_i) - a_i) for a_i in a])
	print(answer)


from math import ceil, floor
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	sum = 0
	for i in a:
		sum ^= i
	ans = 10000000000000
	for i in a:
		ans = min(ans, abs(i - (sum ^ i)))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	xor_value = arr[0]
	for i in range(1, n):
		xor_value = xor_value ^ arr[i]
	mini = xor_value
	for j in range(n):
		ans = xor_value ^ arr[j]
		if mini > abs(ans - arr[j]):
			mini = abs(ans - arr[j])
	print(mini)