Chef has a binary array in an unsorted manner. Cheffina challenges chef to find the transition point in the sorted (ascending) binary array. Here indexing is starting from 0.
Note: Transition point always exists.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains two lines of input, $N$.
- N space-separated binary numbers. 

-----Output:-----
For each test case, output in a single line answer.

-----Constraints-----
- $1 \leq T \leq 10$
- $1 \leq N \leq 10^5$

-----Sample Input:-----
1
5
0 1 0 0 1

-----Sample Output:-----
3

-----EXPLANATION:-----
binary array in sorted form will look like = [0, 0, 0, 1, 1]

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
for _ in range(int(input())):
    n=int(input())
    A=list(map(int,input().split()))
    A.sort()
    for i in range(len(A)):
        if A[i]==1:
            print(i)
            break

for x in range(int(input())):
    n = int(input())
    S = list(map(int,input().split()))
    ind = n - sum(S)
    print(ind)

from sys import*
input=stdin.readline
t=int(input())
for _ in range(t):
    n=int(input())
    l=[int(x) for x in input().split()]
    l.sort()
    print(l.index(1))


list = []

x = int(input())
output = []
for i in range(x):
    count = 0
    val = int(input())
    line = input()
    z = line.split()
    z = [int(y) for y in z]
    for j in z:
        if j == 0:
            count += 1
    
    output.append(count)
for i in output:
    print(i)

# cook your dish here
list = []

x = int(input())
output = []
for i in range(x):
    count = 0
    val = int(input())
    line = input()
    z = line.split()
    z = [int(y) for y in z]
    for j in z:
        if j == 0:
            count += 1
    
    output.append(count)
for i in output:
    print(i)

list = []

x = int(input())
output = []
for i in range(x):
    count = 0
    val = int(input())
    line = input()
    z = line.split()
    z = [int(y) for y in z]
    for j in z:
        if j == 0:
            count += 1
    
    output.append(count)
for i in output:
    print(i)

try:
    for i in range(int(input())):
        n=int(input())
        l=sorted(list(map(int,input().split())))
        print(l.count(0))
except Exception:
    pass
	

t=int(input())
while(t):
    n=int(input())
    l=list(map(int,input().split()))
    print(l.count(0))
    t=t-1

T=int(input())
for i in range(T):
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    for i in range(n):
        if a[i]!=a[i+1]:
            print(i+1)
            break


for i in range(int(input())):
    size = int(input())
    num = list(map(int,input().split()))
    print(num.count(0))
        

def find(arr, n):
    for i in range(n):
        if(arr[i] == 1):
            return i
    
    return -1

t=int(input())
for x in range(t):
    n=int(input())
    arr=list(map(int,input().split()))
    arr.sort()
    p = find(arr, n)
    if p >= 0:
        print(p)

# cook your dish here
t=int(input())
for i in range(t):
    n=int(input())
    l=list(map(int,input().split()))
    l.sort()
    x=l.index(1)
    print(x)


# cook your dish here
t=int(input())
for i in range(t):
    n=int(input())
    x=list(map(int,input().split()))
    x.sort()
    print(x.index(1))

t=int(input())
for i in range(t):
    a=int(input())
    b=[int(b) for b in input().split()]
    b.sort()
    for j in range(len(b)):
        if b[j]==0 and b[j+1]==1:
            print(j+1)
            break

t = int(input())
for _ in range(t):
    n = int(input())
    arr = list(map(int , input().split()))
    arr.sort()
    i = 0
    while arr[i] != 1:
        i += 1
    print(i)

# cook your dish here
n=int(input())
for _ in range(n):
    m=int(input())
    lis=list(map(int,input().strip().split()))
    lis.sort()
    print(lis.index(1))

# cook your dish here
for _ in range(int(input())):
    n = int(input())
    a = list(map(int,input().split()))
    c = a.count(1)
    print(n-c)

t=int(input())
for i in range(t):
    n=int(input())
    l=[int(l) for l in input().split()]
    p=l.count(0)
    print(p)


from sys import stdin, stdout
def findTransitionPoint(arr, n):
	lb = 0
	ub = n - 1
	while (lb <= ub):
		mid = (int)((lb + ub) / 2)
		if (arr[mid] == 0):
			lb = mid + 1
		elif (arr[mid] == 1):
			if (mid == 0 \
				or (mid > 0 and\
				arr[mid - 1] == 0)):
				return mid
			ub = mid-1
	return -1
test = int(stdin.readline())
for _ in range(test):
    n = int(stdin.readline())
    arr = sorted(list(map(int, stdin.readline().split())))
    pp = findTransitionPoint(arr, n);
    print(pp)



# cook your dish here
t = int(input())
for i in range(t):
    N = int(input())
    lst = list(map(int,input().split()))
    count = 0
    lst.sort()
    for j in lst:
        if j == 0 :
            count = count+1 
    print(count)        


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    l.sort()
    for i in range(n-1):
        if l[i] != l[i+1]:
            print(i+1)

# cook your dish here
testcases = int(input())
for x in range(testcases):
    N = map(int,input().split())
    A = sorted(list(map(int,input().split())))
    print(A.count(0))
   

def findTransitionPoint(arr, n):
    lb = 0
    ub = n - 1

    while (lb <= ub):

        mid = (int)((lb + ub) / 2)
 
        if (arr[mid] == 0):
            lb = mid + 1

        elif (arr[mid] == 1):

            if (mid == 0 \
                or (mid > 0 and\
                arr[mid - 1] == 0)):
                return mid

            ub = mid-1
     
    return -1
 

for _ in range(int(input())):
    n = int(input())
    nn = list(map(int,input().split(" ")))
    nn = sorted(nn)
    # res = 0
    # for ele in nn: 
    #     res = (res << 1) | ele 
    # print(res)


    arr = nn
    n = len(arr)
    point = findTransitionPoint(arr, n);
    print(point)
    

# cook your dish here
testcases = int(input())
for x in range(testcases):
    N = int(input())
    A = list(map(int,input().split()))
    print(A.count(0))

t=int(input())
while(t):
    n=int(input())
    a=[]
    p=0
    a=list(map(int,input().split()))
    for i in range(0,n):
        if(a[i]==0):
           p=p+1
    print(p)
    t=t-1