#include<stdio.h>
int main()
{
          long long int n,i,count=0;
          scanf("%lld",&n);
          long long int a[n];
          for(i=0;i<n;i++)
          {
                    scanf("%lld",&a[i]);
          }
          for(i=0;i<n;i++)
          {
                    if(a[i]>=2)
                    {
                              while(a[i]!=1)
                              {
                                        a[i]=a[i]-1;
                                        count++;
                              }
                    }
                    else if(a[i]==0 || a[i]==-1 )
                    {
                              while(a[i]!=1)
                              {
                                        a[i]=a[i]+1;
                                        count++;
                              }
                    }
                    else if(a[i]<-1)
                    {
                              while(a[i]!=-1)
                              {
                                        a[i]=a[i]+1;
                                        count++;
                              }
                    }
          }

           printf("%lld\n",count);
           return 0;
}


#include<stdio.h>
int main()
{

          long long int n,i,ans=0,even=0,zero=0;
	scanf("%lld",&n);
	long long int a[n];
	for( i=0;i<n;i++)
	{
	    scanf("%lld",&a[i]);
	}
	for(int i=0;i<n;i++)
	{
	    if(a[i]>0)
	    {
	        ans=ans+a[i]-1;
	    }
	    if(a[i]<0)
	    {
	        ans=ans+(-a[i]-1);
	        even++;
	    }

	    if(a[i]==0)
	    zero++;
	}

	if(even%2==0)
	{
	    if(zero==0)
	    {
	        ans=ans;
	    }
	    else
	    {
	        while(zero--)
	        {
	            ans+=1;
	        }
	    }
	}
	else
	{
	    if(zero==0)
	    {
	        ans+=2;
	    }
	    else
	    {
	         while(zero--)
	        {
	            ans+=1;
	        }
	    }
	}

         printf("%lld\n",ans);

	return 0;
}


#include<stdio.h>
int main()
 {
          long long int n,i,count=0,ans=0,z=0;
	scanf("%lld",&n);
	long long int a[n];
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		if(a[i]==0)
		{	ans++;
			z++;
		}
		else if(a[i]>0)
			ans=ans+a[i]-1;
		else
		{
			count++;
			ans=ans-1-a[i];
		}
	}
	if(count==1 && z==0)
		ans=ans+2;

	printf("%lld\n",ans);

	return 0;

 }


#include<stdio.h>
int main()
{
          long long int n,i,count=0;
          scanf("%lld",&n);
          long long int a[n];
          for(i=0;i<n;i++)
          {
                    scanf("%lld",&a[i]);
          }
          for(i=0;i<n;i++)
          {
                    if(a[i]>1)
                    {
                              while(a[i]!=1)
                              {
                                        a[i]=a[i]-1;
                                        count++;
                              }
                    }
                    else if(a[i]==0 || a[i]==-1 )
                    {
                              while(a[i]!=1)
                              {
                                        a[i]=a[i]+1;
                                        count++;
                              }
                    }
                    else if(a[i]<-1)
                    {
                              while(a[i]!=-1)
                              {
                                        a[i]=a[i]+1;
                                        count++;
                              }
                    }
          }

           printf("%lld\n",count);
           return 0;
}


#include<stdio.h>
int main()
{
          long long int n,i,count=0;
          scanf("%lld",&n);
          long long int a[n];
          for(i=0;i<n;i++)
          {
                    scanf("%lld",&a[i]);
          }
          for(i=0;i<n;i++)
          {
                    if(a[i]>=0)
                    {
                              while(a[i]!=-1)
                              {
                                        a[i]=a[i]-1;
                                        count++;
                              }
                    }
                    else if(a[i]<0)
                    {
                              while(a[i]!=-1)
                              {
                                        a[i]=a[i]+1;
                                        count++;
                              }
                    }
          }

           printf("%lld\n",count);
           return 0;
}


#include <stdio.h>

int main()
{

    int b,count = 0;
    scanf("%d",&b);
    while(b < 0)
    {
        printf("Error\nPlease Enter Value Greater than Zero\n");
        scanf("%d",&b);
    }
    int a[b];
    int flag = 1;
    for(int i = 0; i < b; i++)
    {
        scanf("%d",a+i);
    }

    for(int i =0; i < b;i++)
    {
        if(a[i] == 0)
        {
            a[i] = 1;
            count++;
            flag = flag*a[i];
        }
        else if(a[i] > 0)
        {
            int c = a[i] -1;
            count += c;
            a[i] = a[i] - c;
            flag = flag * a[i];
        }
        else if(a[i] < 0)
        {
            int c = -a[i] - 1;
            if(i+1 == b-1)
            {
                if(flag * (a[i]+c) == -1)
                {
                    int d = (a[i]+c)+2;
                    count += 2;
                    a[i] = (a[i]+c)+2;
                    flag = flag * a[i];
                }
            }
            else
            {
                count += c;
                a[i] = a[i] + c;
                flag = flag * a[i];
            }
        }

    }

     printf("%d\n",count);

    for(int i =0; i < b;i++)
        printf("%d ",a[i]);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0;
    scanf("%d",&inp);

    while(inp < 1 || inp > 100000)
    {
        scanf("%d",&inp);
    }

    int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%d",a+j);

    }
    int c = 0,val = 0,negCount = 0,flag = 0;
     for(int j = 0; j < inp; j++)
     {
         if(a[j] == 0)
         {
             c++;
         }
         else if(a[j] > 1)
         {
             c += a[j] - 1;
         }
         else if(a[j] <= -1)
         {
            val += -a[j];
            negCount++;
            flag = 1;
         }
     }

     if(flag == 1)
     {
     if(negCount == 1)
     {
        c += val + 2;
     }
     else if(negCount % 2 == 0)
     {
        c += val - negCount;
     }
     else
     {
        c += val - (negCount - 1);
        c += 2;
     }
     }

     printf("%d\n",c);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0;
    scanf("%d",&inp);

    while(inp < 1 || inp > 100000)
    {
        scanf("%d",&inp);
    }

    int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%d",a+j);

    }
    int c = 0,val = 0,negCount = 0,flag = 0;
     for(int j = 0; j < inp; j++)
     {
         if(a[j] == 0)
         {
             c++;
         }
         else if(a[j] > 1)
         {
             c += a[j] - 1;
         }
         else if(a[j] <= -1)
         {
            val += -a[j];
            negCount++;
            flag = 1;
         }
     }

     if(flag == 1)
     {
     if(negCount == 1)
     {
        c += val + 1;
     }
     else if(negCount % 2 == 0)
     {
        c += val - negCount;
     }
     else
     {
        c += val - (negCount - 1);
        c += 2;
     }
     }

     printf("%d\n",c);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0;
    scanf("%d",&inp);

    while(inp < 1 || inp > 100000)
    {
        scanf("%d",&inp);
    }

    int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%d",a+j);
    }
    int c = 0,val = 0,negCount = 0,flag = 0;

     for(int j = 0; j < inp; j++)
     {
         if(a[j] == 0)
         {
             c++;
         }
         else if(a[j] > 1)
         {
             c += a[j] - 1;
         }
         else if(a[j] <= -1)
         {
            val += -a[j];
            negCount++;
            flag = 1;
         }
     }

     if(flag == 1)
     {
     if(negCount == 1)
     {
        c += 2;
     }
     else if(negCount % 2 == 0)
     {
        c += val - negCount;
     }
     else
     {
        c += val - (negCount - 1);
        c += 2;
     }
     }

     printf("%d\n",c);

    return 0;
}


#include <stdio.h>

int find(int a[],int inp,int start);

int main()
{
    long long inp = 0, count = 0, negFlag = 0, temp = 0;
    scanf("%d",&inp);

    int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%d",a+j);

        if(a[j] < 0 && negFlag == 1)
        {
            negFlag = 0;
            count += (-a[j]) - 1;
            count += (-temp) - 1;
        }
        else if(a[j] < 0 && negFlag == 0)
        {
            negFlag = 1;
            temp = a[j];
        }
        else if(a[j] == 0 && negFlag == 0)
        {
            count++;
        }
        else if(a[j] == 0 && negFlag == 1)
        {
            negFlag = 0;
            count ++;
            count += (-temp) - 1;
        }
        else if(a[j] > 0)
        {
            count += a[j] - 1;
        }
    }

    if(negFlag == 1)
    {
        count += (-temp) + 1;
    }

    printf("%d",count);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0, negFlag = 0,zeroFlag = 0,tempZero = 0;
    unsigned long long count = 0;
    signed long long int tempNeg = 0;

    scanf("%d",&inp);

    signed long long int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%I64d",a+j);

        if(a[j] > 0)
        {
            count += a[j] - 1;
        }
        else if(a[j] < 0 && zeroFlag == 0 && negFlag == 0)
        {
            negFlag = 1;
            tempNeg = a[j];
        }
        else if(a[j] < 0 && zeroFlag == 0 && negFlag == 1)
        {
            negFlag = 0;
            count += (-a[j]) - 1;
            count += (-tempNeg) - 1;
            tempNeg = 0;
        }
        else if(a[j] < 0 && zeroFlag == 1 && negFlag == 0)
        {
            negFlag = 1;
            tempNeg = a[j];
        }
        else if(a[j] < 0 && zeroFlag == 1 && negFlag == 1)
        {
            //negFlag = 0;
            //count += (-tempNeg) - 1;
            count += (-a[j]) - 1;
        }
        else if(a[j] == 0 && zeroFlag == 0 && negFlag == 0)
        {
            zeroFlag = 1;
        }
        else if(a[j] == 0 && zeroFlag == 0 && negFlag == 1)
        {
            zeroFlag = 1;
        }
        else if(a[j] == 0 && zeroFlag == 1 && negFlag == 0)
        {
            count++;
        }
        else if(a[j] == 0 && zeroFlag == 1 && negFlag == 1)
        {
            count++;
        }
    }

    if(negFlag == 0 && zeroFlag == 0)
    {

    }
    else if(negFlag == 0 && zeroFlag == 1)
    {
        zeroFlag = 0;
        count++;
    }
    else if(negFlag == 1 && zeroFlag == 0)
    {
        negFlag = 0;
        count += (-tempNeg) + 1;
    }
    else if(negFlag == 1 && zeroFlag == 1)
    {
        negFlag = 0;
        zeroFlag = 0;
        count += (-tempNeg) - 1;
        count++;
    }

    printf("%I64u",count);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0, negFlag = 0;
    unsigned long long count = 0;
    signed long long int temp = 0;

    scanf("%d",&inp);

    signed long long int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%I64d",a+j);

        if(a[j] < 0 && negFlag == 1)
        {
            negFlag = 0;
            count += (-a[j]) - 1;
            count += (-temp) - 1;
        }
        else if(a[j] < 0 && negFlag == 0)
        {
            negFlag = 1;
            temp = a[j];
        }
        else if(a[j] == 0 && negFlag == 0)
        {
            count++;
        }
        else if(a[j] == 0 && negFlag == 1)
        {
            negFlag = 0;
            count ++;
            count += (-temp) - 1;
        }
        else if(a[j] > 0)
        {
            count += a[j] - 1;
        }
    }

    if(negFlag == 1)
    {
        count += (-temp) + 1;
    }

    printf("%I64u",count);

    return 0;
}


#include <stdio.h>

int main()
{

    int b,count = 0;
    scanf("%d",&b);
    while(b < 0)
    {
        printf("Error\nPlease Enter Value Greater than Zero\n");
        scanf("%d",&b);
    }
    int a[b];
    int flag = 1;
    for(int i = 0; i < b; i++)
    {
        scanf("%d",a+i);
    }

    for(int i =0; i < b;i++)
    {
        if(a[i] == 0)
        {
            a[i] = 1;
            count++;
            flag = flag*a[i];
        }
        else if(a[i] > 0)
        {
            int c = a[i] -1;
            count += c;
            a[i] = a[i] - c;
            flag = flag * a[i];
        }
        else if(a[i] < 0)
        {
            int c = -a[i] - 1;
            if(i+1 == b-1)
            {
                if(flag * (a[i]+c) == -1)
                {
                    int d = (a[i]+c)+2;
                    count += 2;
                    a[i] = (a[i]+c)+2;
                    flag = flag * a[i];
                }
            }
            else
            {
                count += c;
                a[i] = a[i] + c;
                flag = flag * a[i];
            }
        }

    }

     printf("%d\n",count);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0;
    scanf("%d",&inp);

    while(inp < 1 || inp > 100000)
    {
        scanf("%d",&inp);
    }

    int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%d",a+j);
        while(a[j] > 1000000000 || a[j] < 1000000000)
        {
            scanf("%d",a+j);
        }
    }
    int c = 0,val = 0,negCount = 0,flag = 0;
     for(int j = 0; j < inp; j++)
     {
         if(a[j] == 0)
         {
             c++;
         }
         else if(a[j] > 1)
         {
             c += a[j] - 1;
         }
         else if(a[j] <= -1)
         {
            val += -a[j];
            negCount++;
            flag = 1;
         }
     }

     if(flag == 1)
     {
     if(negCount == 1)
     {
        c += 2;
     }
     else if(negCount % 2 == 0)
     {
        c += val - negCount;
     }
     else
     {
        c += val - (negCount - 1);
        c += 2;
     }
     }

     printf("%d\n",c);

    return 0;
}


#include <stdio.h>

int main()
{

    int b,count = 0;
    scanf("%d",&b);
    while(b < 0)
    {
        printf("Error\nPlease Enter Value Greater than Zero\n");
        scanf("%d",&b);
    }
    int a[b];
    int flag = 1;
    for(int i = 0; i < b; i++)
    {
        scanf("%d",a+i);
    }

    for(int i =0; i < b;i++)
    {
        if(a[i] == 0)
        {
            a[i] = 1;
            count++;
            flag = flag*a[i];
        }
        else if(a[i] > 0)
        {
            int c = a[i] -1;
            count += c;
            a[i] = a[i] - c;
            flag = flag * a[i];
        }
        else if(a[i] < 0)
        {
            int c = -a[i] - 1;
            if(i+1 == b-1)
            {
                if(flag * (a[i]+c) == -1)
                {
                    int d = (a[i]+c)+2;
                    count += 2;
                    a[i] = (a[i]+c)+2;
                    flag = flag * a[i];
                }
                else
                {
                    int d = (a[i]+c)+1;
                    count += 2;
                    a[i] = (a[i]+c)+2;
                    flag = flag * a[i];
                }
            }
            else
            {
                count += c;
                a[i] = a[i] + c;
                flag = flag * a[i];
            }
        }

    }

     printf("%d\n",count);

    for(int i =0; i < b;i++)
        printf("%d ",a[i]);

    return 0;
}


#include <stdio.h>

int main()
{
    int inp = 0;
    scanf("%d",&inp);

    while(inp <= 1 || inp > 100000)
    {
        scanf("%d",&inp);
    }

    int a[inp];

    for(int j = 0 ; j < inp; j++)
    {
        scanf("%d",a+j);
    }
    int c = 0,val = 0,negCount = 0;
     for(int j = 0; j < inp; j++)
     {
         if(a[j] == 0)
         {
             c++;
         }
         else if(a[j] > 1)
         {
             c += a[j] - 1;
         }
         else if(a[j] <= -1)
         {
            val += -a[j];
            negCount++;
         }
     }

     if(negCount == 1)
     {
        c += 2;
     }
     else if(negCount % 2 == 0)
     {
        c += val - negCount;
     }
     else
     {
        c += val - (negCount - 1);
        c += 2;
     }

     printf("%d\n",c);

    return 0;
}


#include <stdio.h>

int main()
{

    int b,count = 0;
    scanf("%d",&b);
    while(b < 0)
    {
        scanf("%d",&b);
    }
    int a[b];
    int flag = 1;
    for(int i = 0; i < b; i++)
    {
        scanf("%d",a+i);
    }

    for(int i =0; i < b;i++)
    {
        if(a[i] == 0)
        {
            a[i] = 1;
            count++;
            flag = flag*a[i];
        }
        else if(a[i] > 0)
        {
            int c = a[i] -1;
            count += c;
            a[i] = a[i] - c;
            flag = flag * a[i];
        }
        else if(a[i] < 0)
        {
            int c = -a[i] - 1;
            if(i+1 == b-1)
            {
                if(flag * (a[i]+c) == -1)
                {
                    int d = (a[i]+c)+2;
                    count += 2;
                    a[i] = (a[i]+c)+2;
                    flag = flag * a[i];
                }
            }
            else
            {
                count += c;
                a[i] = a[i] + c;
                flag = flag * a[i];
            }
        }

    }

     printf("%d\n",count);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define pr 0.0000001
long long max(long long a, long long b);
long long min(long long a, long long b);
int comparetor (const void * a, const void * b);//for qsort in ascending order
unsigned long long greatestpowerof2lessthan(unsigned long long a);
//above function has unsigned for more acciracy. so use type casting.
unsigned long long leastpowerof2greaterthan(unsigned long long a);
//above function has unsigned for more acciracy. so use type casting.
int main()
{
    long long n;  scanf("%lld", &n);
    long long arr[1000000] = {0};
    long long count0=0, countn1=0, countp1=0;
    long long coins=0;
    for(long long i=0; i<n; i++)
    {
        scanf("%lld", &arr[i]);
        if(arr[i]<-1)
        {   coins += (-1-arr[i]);
            countn1++;
        }
        else if(arr[i]==-1)
            countn1++;
        else if(arr[i]==0)
            count0++;
        else
        {
            countp1++;
            coins+=(arr[i]-1);
        }
    }
    if(countn1 && countn1%2==1)
    {
        if(count0!=0)
        {
            coins++; count0--; //change this 0 to -1
        }
        else
            coins+=2; //one -1 changes to 1
    }
    coins += count0;

    printf("%lld\n", coins);
    return 0;
}

long long max(long long a, long long b)
{
    if(a>=b)
        return a;
    else
        return b;
}
long long min(long long a, long long b)
{
    if(a<=b)
        return a;
    else
        return b;
}
int comparetor (const void * a, const void * b)
{
		return ( *(int*)a - *(int*)b );
}
unsigned long long greatestpowerof2lessthan(unsigned long long a)
{
    unsigned long long ans=1, curr=1;
    for(int i=0, upperlimit=8*sizeof(unsigned long long); i<upperlimit; i++)
    {
        curr = 1<<i;
        if(curr>a)
            break;
        ans = curr;
    }
    return ans;
}
unsigned long long leastpowerof2greaterthan(unsigned long long a)
{
    unsigned long long curr=1;
    for(int i=0, upperlimit=8*sizeof(unsigned long long); i<upperlimit; i++)
    {
        curr = 1<<i;
        if(curr>=a)
            break;
    }
    return curr;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define pr 0.0000001
long long max(long long a, long long b);
long long min(long long a, long long b);
int comparetor (const void * a, const void * b);//for qsort in ascending order
unsigned long long greatestpowerof2lessthan(unsigned long long a);
//above function has unsigned for more acciracy. so use type casting.
unsigned long long leastpowerof2greaterthan(unsigned long long a);
//above function has unsigned for more acciracy. so use type casting.
int main()
{
    int n;  scanf("%d", &n);
    int arr[1000000] = {0};
    int count0=0, countn1=0, countp1=0;
    int coins=0;
    for(int i=0; i<n; i++)
    {
        scanf("%d", &arr[i]);
        if(arr[i]<-1)
        {   coins += (-1-arr[i]);
            countn1++;
        }
        else if(arr[i]==-1)
            countn1++;
        else if(arr[i]==0)
            count0++;
        else
        {
            countp1++;
            coins+=(arr[i]-1);
        }
    }
    if(countn1 && countn1%2==1)
    {
        if(count0!=0)
        {
            coins++; count0--; //change this 0 to -1
        }
        else
            coins+=2; //one -1 changes to 1
    }
    coins += count0;

    printf("%d\n", coins);
    return 0;
}

long long max(long long a, long long b)
{
    if(a>=b)
        return a;
    else
        return b;
}
long long min(long long a, long long b)
{
    if(a<=b)
        return a;
    else
        return b;
}
int comparetor (const void * a, const void * b)
{
		return ( *(int*)a - *(int*)b );
}
unsigned long long greatestpowerof2lessthan(unsigned long long a)
{
    unsigned long long ans=1, curr=1;
    for(int i=0, upperlimit=8*sizeof(unsigned long long); i<upperlimit; i++)
    {
        curr = 1<<i;
        if(curr>a)
            break;
        ans = curr;
    }
    return ans;
}
unsigned long long leastpowerof2greaterthan(unsigned long long a)
{
    unsigned long long curr=1;
    for(int i=0, upperlimit=8*sizeof(unsigned long long); i<upperlimit; i++)
    {
        curr = 1<<i;
        if(curr>=a)
            break;
    }
    return curr;
}


#include<stdio.h>

int main() {
long int n, i, arr[100007], count=0, x=0, y=0;
scanf("%ld", &n);
for(i=0; i<n; i++)
scanf("%ld", &arr[i]);
for(i=0; i<n; i++){
if(arr[i]<0){
count = count+(-1-arr[i]);
x++;
}
else if(arr[i]>0)
count = count+(arr[i]-1);
else{
count++;
y++;
}
}
if(x%2!=0 && y==0){
count = count+2;
}

printf("%ld\n", count);
return 0;
}


#include<stdio.h>
int main() {
long long int n, i, arr[100007], count=0, x=0, y=0;
scanf("%lld", &n);
for(i=0; i<n; i++)
scanf("%lld", &arr[i]);
for(i=0; i<n; i++){
    if(arr[i]<0){
            count = count + (-1-arr[i]);
            x++;
    }
    else if(arr[i]>0)
    count = count+(arr[i]-1);
    else{
        count++;
        y++;
    }
}
if(x%2!=0 && y==0){
    count= count+2;
}
printf("%lld\n", count);
return 0;
}


#include<stdio.h>

int main() {
long int n, i, arr[100007], count=0, x=0;
scanf("%ld", &n);
for(i=0; i<n; i++)
scanf("%ld", &arr[i]);
for(i=0; i<n; i++){
if(arr[i]<0){
count = count+(-1-arr[i]);
x++;
}
else if(arr[i]>0)
count = count+(arr[i]-1);
else
count++;
}

if(x%2!=0){
count = count+2;
}
printf("%ld\n", count);
return 0;
}


#include <stdio.h>
//#include <stdlib.h>

int main(int argc, char const *argv[]) {
  long long int sum=0;
  int n, a, zero = 0, right = 0, left = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if(a < 0) {
      sum += (-1)-a;
      left ++;
    }
    if (a == 0) zero++;
    if(a > 0){
      sum += a-1;
      right ++;
    }
  }
  if ((left % 2) <= zero) sum += zero;
  else sum += (left % 2) - zero;
  printf("%I64d\n", sum);
  return 0;
}


#include <stdio.h>
//#include <stdlib.h>

int main(int argc, char const *argv[]) {
  long long int sum=0;
  int n, a, zero = 0, right = 0, left = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if(a < 0) {
      sum += (-1)-a;
      left ++;
    }
    else if (a == 0) zero++;
    else if(a > 0){
      sum += a-1;
      right ++;
    }
  }
  if ((left % 2) + (right % 2) <= zero) sum += zero;
  else sum += (left % 2) + (right % 2) - zero;
  printf("%I64d\n", sum);
  return 0;
}


#include <stdio.h>
//#include <stdlib.h>

int main(int argc, char const *argv[]) {
  long long int sum=0;
  int n, a, zero = 0, right = 0, left = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if(a < 0) {
      sum += (-1)-a;
      left ++;
    }
    if (a == 0) zero++;
    if(a > 0){
      sum += a-1;
      right ++;
    }
  }
  if ((left % 2) <= zero) sum += zero;
  else sum += 2*((left % 2) - zero);
  printf("%I64d\n", sum);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define N 100000

// int cmpfunc (const void * a, const void * b) {
//    return ( *(int*)a - *(int*)b );
// }

   // qsort(values, 5, sizeof(int), cmpfunc);
int min(int a, int b)
{
	return (a < b ? a : b);
}

int main() {
	int n, i;
	int aa[N];
	long long dp[N][2];
	scanf("%d", &n);
	i = -1;
	while(++i < n){
		scanf("%d", &aa[i]);

	}

	dp[0][0] = abs(aa[0] - (-1));
	dp[0][1] = abs(aa[0] - 1);

	i = 0;
	while(++i < n){
		dp[i][0] = min(dp[i-1][1] + abs (aa[i]- (-1)),dp[i-1][0] + abs (aa[i]- (1)) );
		dp[i][1] = min(dp[i-1][1] + abs (aa[i]- (1)),dp[i-1][0] + abs (aa[i]- (-1)) );
	}

	printf("%lld\n", dp[n-1][1]);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define N 100000

long long my_abs(long long a)
{
	if (a>0)
		return a;
	return (-a);

}

// int cmpfunc (const void * a, const void * b) {
//    return ( *(int*)a - *(int*)b );
// }

   // qsort(values, 5, sizeof(int), cmpfunc);
long long min(long long a, long long b)
{
	return (a < b ? a : b);
}

int main() {
	int n, i;
	long long aa[N];
	long long dp[N][2];
	scanf("%d", &n);
	i = -1;
	while(++i < n){
		scanf("%lld", &aa[i]);

	}

	dp[0][0] = my_abs(aa[0] - (-1));
	dp[0][1] = my_abs(aa[0] - 1);

	i = 0;
	while(++i < n){
		dp[i][0] = min(dp[i-1][1] + my_abs (aa[i]- (-1)),dp[i-1][0] + my_abs (aa[i]- (1)) );
		dp[i][1] = min(dp[i-1][1] + my_abs (aa[i]- (1)),dp[i-1][0] + my_abs (aa[i]- (-1)) );
	}

	printf("%lld\n", dp[n-1][1]);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define N 100000

long long my_abs(long long a)
{
	if (a>0)
		return a;
	return (-a);

}

// int cmpfunc (const void * a, const void * b) {
//    return ( *(int*)a - *(int*)b );
// }

   // qsort(values, 5, sizeof(int), cmpfunc);
int min(int a, int b)
{
	return (a < b ? a : b);
}

int main() {
	int n, i;
	long long aa[N];
	long long dp[N][2];
	scanf("%d", &n);
	i = -1;
	while(++i < n){
		scanf("%lld", &aa[i]);

	}

	dp[0][0] = my_abs(aa[0] - (-1));
	dp[0][1] = my_abs(aa[0] - 1);

	i = 0;
	while(++i < n){
		dp[i][0] = min(dp[i-1][1] + my_abs (aa[i]- (-1)),dp[i-1][0] + my_abs (aa[i]- (1)) );
		dp[i][1] = min(dp[i-1][1] + my_abs (aa[i]- (1)),dp[i-1][0] + my_abs (aa[i]- (-1)) );
	}

	printf("%lld\n", dp[n-1][1]);

	return 0;
}


#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int p=0, ne=0, z=0, a[n];
	for (int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		if (a[i]>0) p++;
		else if (a[i]<0) ne++;
		else z++;
	}
	if (ne%2==0) {
		long long int c=0;
		for (int i=0;i<n;i++) {
			if (a[i]==0) c++;
			else {
				if (a[i]>0) c+=a[i]-1;
				else c+=(a[i]+1)*-1;
			}
		}
		printf("ll%d\n", c);
	}
	else {
		long long int c=0;
		for (int i=0;i<n;i++) {
			if (a[i]==0) c++;
			else {
				if (a[i]>0) c+=a[i]-1;
				else c+=(a[i]+1)*-1;
			}
		}
		if (z>0) printf("%lld\n", c);
		else printf("%lld\n", c+2);
	}
}


#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int p=0, ne=0, z=0, a[n];
	for (int i=0;i<n;i++) {
		scanf("%d", &a[i]);
		if (a[i]>0) p++;
		else if (a[i]<0) ne++;
		else z++;
	}
	if (ne%2==0) {
		long long int c=0;
		for (int i=0;i<n;i++) {
			if (a[i]==0) c++;
			else {
				if (a[i]>0) c+=a[i]-1;
				else c+=(a[i]+1)*-1;
			}
		}
		printf("%lld\n", c);
	}
	else {
		long long int c=0;
		for (int i=0;i<n;i++) {
			if (a[i]==0) c++;
			else {
				if (a[i]>0) c+=a[i]-1;
				else c+=(a[i]+1)*-1;
			}
		}
		if (z>0) printf("%lld\n", c);
		else printf("%lld\n", c+2);
	}
}


#include<stdio.h>

#include<string.h>
int main()
{
    long long int ch[100000];
    char arr[1000000];
    char kh[1000000],bh,ag;
    int cp[400];
    long long int a,b,c,d,e=0,g,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    scanf("%lld",&a);

    j=0;
    k=0;
    for(i=1; i<=a; i++)
    {
        scanf("%lld",&b);
        if(b==0)
        {
            j++;
        }
        else if(b>0)
        {
            j+=b;
            k++;

        }
        else
        {
            j-=b;
            k++;
        }

    }
    if(j-k!=0)
        printf("%lld\n",j-k);
    else
        printf("2\n");
    return 0;
}


#include<stdio.h>

#include<string.h>
int main()
{
    long long int ch[100000];
    char arr[1000000];
    char kh[1000000],bh,ag;
    int cp[400];
    long long int a,b,c,d,e=0,g,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    scanf("%lld",&a);

    j=0;
    k=0;
    for(i=1; i<=a; i++)
    {
        scanf("%lld",&b);
        if(b==0)
        {
            j++;
        }
        else if(b>0)
        {
            j+=b;
            k++;

        }
        else
        {
            j-=b;
            k++;
        }

    }
    if(k==1 && b<=0)
     printf("%lld\n",j+1);
    else if(k==1 && b>0)
      printf("%lld\n",j-1);
    else if(j-k!=0)
        printf("%lld\n",j-k);
    else
        printf("2\n");
    return 0;
}


#include<stdio.h>

#include<string.h>
int main()
{
    long long int ch[100000];
    char arr[1000000];
    char kh[1000000],bh,ag;
    int cp[400];
    long long int a,b,c,d,e=0,g,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    scanf("%lld",&a);

    j=0;
    k=0;
    for(i=1; i<=a; i++)
    {
        scanf("%lld",&b);
        if(b==0)
        {
            j++;
        }
        else if(b>0)
        {
            j+=b;
            k++;

        }
        else
        {
            j-=b;
            k++;
        }

    }
    if(j-k!=0)
        printf("%lld\n",j-k);
    else
        printf("2\n",);
    return 0;
}


#include<stdio.h>

#include<string.h>
int main()
{
    long long int ch[100000];
    char arr[1000000];
    char kh[1000000],bh,ag;
    int cp[400];
    long long int a,b,c,d,e=0,g,i=0,tep=0,temp=0,j=0,k=0,l=0,m=0,n=0;
    scanf("%lld",&a);

    j=0;
    k=0;
    for(i=1; i<=a; i++)
    {
        scanf("%lld",&b);
        if(b==0)
        {
            j++;
        }
        else if(b>0)
        {
            j+=b;
            k++;

        }
        else
        {
            j-=b;
            k++;
        }

    }
    if(k==1 && b<=0)
     printf("%d\n",j+1);
    else if(k==1 && b>0)
      printf("%d\n",j-1);
    else if(j-k!=0)
        printf("%lld\n",j-k);
    else
        printf("2\n");
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    int numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%d", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] < 0)
        {
            coins = coins + (-1 - numbers[i]);
            numofneg++;
        }
        else if(numbers[i] > 0)
        {
            coins = coins + (numbers[i] - 1);
            numofpos++;
        }
        else
        {
            coins = coins + 1;
        }
    }

    if(numofneg % 2 == 0)
    {
        printf("%d", coins);
    }
    else
    {
        printf("%d", coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    int numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%d", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] < 0)
        {
            coins = coins + (-1 - numbers[i]);
            numofneg++;
        }
        else if(numbers[i] > 0)
        {
            coins = coins + (numbers[i] - 1);
            numofpos++;
        }
        else
        {
            coins = coins + 1;
        }
    }

    if(numofpos == numofneg)
    {
        printf("%d\n", coins);
    }
    else
    {
        printf("%d\n", coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    int numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%d", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
                numofpos++;
            }
            else
            {
                coins = coins + 1;
            }
        }
        else
        {
            if(numbers[i] == 1)
            {
                numofpos +=1;
            }
            else
            {
                numofneg += 1;
            }
    }
    }

    if(numofneg % 2 == 0)
    {
        printf("%d", coins);
    }
    else
    {
        printf("%d", coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    long numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%lu", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1 && numbers[i] != 0)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
            }

        }
        else if (numbers[i] == -1)
        {
            numofneg++;
        }

    }

    for (int i = 0; i < numofnum; i++)
    {
        if (numbers[i] == 0)
        {
            if (numofneg % 2 != 0)
            {
                coins += 1;
                numofneg++;
            }
            else
            {
                coins += 1;
            }
        }
    }

    if(numofneg % 2 == 0)
    {
        printf("%d", coins);
    }
    else
    {
        printf("%d", coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int64_t coins = 0;

    scanf("%d", &numofnum);

    int64_t numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%" SCNd64 , &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1 && numbers[i] != 0)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
            }

        }
        else if (numbers[i] == -1)
        {
            numofneg++;
        }

    }

    for (int i = 0; i < numofnum; i++)
    {
        if (numbers[i] == 0)
        {
            if (numofneg % 2 != 0)
            {
                coins += 1;
                numofneg++;
            }
            else
            {
                coins += 1;
            }
        }
    }

    if(numofneg % 2 == 0)
    {
        printf("%" SCNd64 , coins);
    }
    else
    {
        printf("%" SCNd64, coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    long numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%l", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1 && numbers[i] != 0)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
            }

        }
        else if (numbers[i] == -1)
        {
            numofneg++;
        }

    }

    for (int i = 0; i < numofnum; i++)
    {
        if (numbers[i] == 0)
        {
            if (numofneg % 2 != 0)
            {
                coins += 1;
                numofneg++;
            }
            else
            {
                coins += 1;
            }
        }
    }

    if(numofneg % 2 == 0)
    {
        printf("%d", coins);
    }
    else
    {
        printf("%d", coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    int numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%d", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1 && numbers[i] != 0)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
                numofpos++;
            }

        }
        else if (numbers[i] == 0)
        {
            if (numofneg % 2 != 0)
            {
                coins += 1;
                numofneg++;
            }
            else
            {
                coins += 1;
            }
        }
        else if (numbers[i] == -1)
        {
            numofneg++;
        }

    }

    if(numofneg % 2 == 0)
    {
        printf("%d", coins);
    }
    else
    {
        printf("%d", coins+2);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int64_t coins = 0;

    scanf("%d", &numofnum);

    int64_t numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%" SCNd64 , &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1 && numbers[i] != 0)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
            }

        }
        else if (numbers[i] == -1)
        {
            numofneg++;
        }

    }

    for (int i = 0; i < numofnum; i++)
    {
        if (numbers[i] == 0)
        {
            if (numofneg % 2 != 0)
            {
                coins += 1;
                numofneg++;
            }
            else
            {
                coins += 1;
            }
        }
    }

    if(numofneg % 2 == 0)
    {
        printf("%" SCNd64 , coins);
    }
    else
    {
        printf("%" SCNd64, coins+2);
    }
}s


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int numofnum= 0;
    int numofpos = 0;
    int numofneg = 0;
    int coins = 0;

    scanf("%d", &numofnum);

    int numbers[numofnum];

    for (int i=0; i < numofnum; i++)
    {
        scanf("%d", &numbers[i]);
    }

    //calculate minimun number of coins and count number of positive and negative integers
    for(int i = 0; i < numofnum; i++)
    {
        if(numbers[i] != 1  && numbers[i] != -1 && numbers[i] != 0)
        {
            if(numbers[i] < 0 )
            {
                coins = coins + (-1 - numbers[i]);
                numofneg++;
            }
            else if(numbers[i] > 0)
            {
                coins = coins + (numbers[i] - 1);
            }

        }
        else if (numbers[i] == -1)
        {
            numofneg++;
        }

    }

    for (int i = 0; i < numofnum; i++)
    {
        if (numbers[i] == 0)
        {
            if (numofneg % 2 != 0)
            {
                coins += 1;
                numofneg++;
            }
            else
            {
                coins += 1;
            }
        }
    }

    if(numofneg % 2 == 0)
    {
        printf("%d", coins);
    }
    else
    {
        printf("%d", coins+2);
    }
}


#include <bits/stdc++.h>
#include<string>
using namespace std;

typedef long long int ll;
typedef string St;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;

typedef set<int> si;
typedef set<char> sc;

typedef pair<int,int> pi;
typedef pair<char,int> pc;

typedef map<int,int> mi;
typedef map<string,int> ms;

typedef vector<pi> vpi;
typedef vector<pc> vpc;

typedef map<int, int>::iterator miitr;
typedef map<string, int>::iterator msitr;

/* Hash maps element access*/
#define F first
#define S second

/* STL data functions*/
#define PB push_back
#define MP make_pair

/* binary search functions*/
#define UB upper_bound
#define LB lower_bound
#define ER equal_range

/* Loops */
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define ROF(i,a,b) for (int i = a; i >=b; i--)

int main ()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll t,n,x;
	long double y;
	vector<ll> v;

	cin>>t;

	while(t--)
	{
		cin>>n;
		v.clear();

		FOR(i,0,n-1)
		{
			cin>>x;
			v.PB(x);
		}

		x=0;

		FOR(i,1,n-1)
		{
			if(v[i]+x<v[i-1])
			{
				y=log2(v[i-1]-v[i]+1);
				if(y-round(y)!=0)
				x=y+1;
				else
				x=y;
				v[i]+=pow(2,x)-1;
			}
		}
		cout<<x<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include<string>
using namespace std;

typedef long long int ll;
typedef string St;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;

typedef set<int> si;
typedef set<char> sc;

typedef pair<int,int> pi;
typedef pair<char,int> pc;

typedef map<int,int> mi;
typedef map<string,int> ms;

typedef vector<pi> vpi;
typedef vector<pc> vpc;

typedef map<int, int>::iterator miitr;
typedef map<string, int>::iterator msitr;

/* Hash maps element access*/
#define F first
#define S second

/* STL data functions*/
#define PB push_back
#define MP make_pair

/* binary search functions*/
#define UB upper_bound
#define LB lower_bound
#define ER equal_range

/* Loops */
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define ROF(i,a,b) for (int i = a; i >=b; i--)

int main ()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll t,n,x,z;
	long double y;
	vector<ll> v;

	cin>>t;

	while(t--)
	{
		cin>>n;
		v.clear();

		FOR(i,0,n-1)
		{
			cin>>x;
			v.PB(x);
		}

		x=0;
		z=0;
		FOR(i,1,n-1)
		{
			if(v[i] < v[i-1])
			{
				y=log2(v[i-1]-v[i]+1);
				if(y-round(y)!=0)
				x=y+1;
				else
				x=y;
				v[i]+=pow(2,x);
				while(1)
				{
					z = v[i]-v[i-1];
					if(z>0)
					{
						z = log2(z);
						v[i]-=pow(2,z);
					}
					else
					break;
				}
			}
		}
		cout<<x<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include<string>
using namespace std;

typedef long long int ll;
typedef string St;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;

typedef set<int> si;
typedef set<char> sc;

typedef pair<int,int> pi;
typedef pair<char,int> pc;

typedef map<int,int> mi;
typedef map<string,int> ms;

typedef vector<pi> vpi;
typedef vector<pc> vpc;

typedef map<int, int>::iterator miitr;
typedef map<string, int>::iterator msitr;

/* Hash maps element access*/
#define F first
#define S second

/* STL data functions*/
#define PB push_back
#define MP make_pair

/* binary search functions*/
#define UB upper_bound
#define LB lower_bound
#define ER equal_range

/* Loops */
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define ROF(i,a,b) for (int i = a; i >=b; i--)

int main ()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll t,n,x,z;
	long double y;
	vector<ll> v;

	cin>>t;

	while(t--)
	{
		cin>>n;
		v.clear();

		FOR(i,0,n-1)
		{
			cin>>x;
			v.PB(x);
		}

		x=0;
		z=0;
		FOR(i,1,n-1)
		{
			z=max(z,v[i]);
			if(v[i]+pow(2,x)-1 < z)
			{
				y=log2(z-v[i]+1);
				if(y-round(y)!=0)
				x=y+1;
				else
				x=y;
			}
		}
		cout<<x<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include<string>
using namespace std;

typedef long long int ll;
typedef string St;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;

typedef set<int> si;
typedef set<char> sc;

typedef pair<int,int> pi;
typedef pair<char,int> pc;

typedef map<int,int> mi;
typedef map<string,int> ms;

typedef vector<pi> vpi;
typedef vector<pc> vpc;

typedef map<int, int>::iterator miitr;
typedef map<string, int>::iterator msitr;

/* Hash maps element access*/
#define F first
#define S second

/* STL data functions*/
#define PB push_back
#define MP make_pair

/* binary search functions*/
#define UB upper_bound
#define LB lower_bound
#define ER equal_range

/* Loops */
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define ROF(i,a,b) for (int i = a; i >=b; i--)

int main ()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll t,n,x,z,m;
	long double y;
	vector<ll> v;

	cin>>t;

	while(t--)
	{
		cin>>n;
		v.clear();

		FOR(i,0,n-1)
		{
			cin>>x;
			v.PB(x);
		}

		x=0;
		z=0;
		m=0;

		FOR(i,1,n-1)
		{
			if(v[i] < v[i-1])
			{
				y=log2(v[i-1]-v[i]+1);
				if(y-round(y)!=0)
				x=y+1;
				else
				x=y;
				v[i]+=pow(2,x);
				while(1)
				{
					z = v[i]-v[i-1];
					if(z>0)
					{
						z = log2(z);
						v[i]-=pow(2,z);
					}
					else
					break;
				}
				m=max(m,x);
			}
		}
		cout<<m<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#include<string>
using namespace std;

typedef long long int ll;
typedef string St;

typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vc> vvc;

typedef set<int> si;
typedef set<char> sc;

typedef pair<int,int> pi;
typedef pair<char,int> pc;

typedef map<int,int> mi;
typedef map<string,int> ms;

typedef vector<pi> vpi;
typedef vector<pc> vpc;

typedef map<int, int>::iterator miitr;
typedef map<string, int>::iterator msitr;

/* Hash maps element access*/
#define F first
#define S second

/* STL data functions*/
#define PB push_back
#define MP make_pair

/* binary search functions*/
#define UB upper_bound
#define LB lower_bound
#define ER equal_range

/* Loops */
#define FOR(i,a,b) for (int i = a; i <= b; i++)
#define ROF(i,a,b) for (int i = a; i >=b; i--)

int main ()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	ll t,n,x,z;
	long double y;
	vector<ll> v;

	cin>>t;

	while(t--)
	{
		cin>>n;
		v.clear();

		FOR(i,0,n-1)
		{
			cin>>x;
			v.PB(x);
		}

		x=0;
		z=0;
		FOR(i,1,n-1)
		{
			if(v[i] < v[i-1])
			{
				y=log2(z-v[i]+1);
				if(y-round(y)!=0)
				x=y+1;
				else
				x=y;
				v[i]+=pow(2,x);
				while(1)
				{
					z = v[i]-v[i-1];
					if(z>0)
					{
						z = log2(z);
						v[i]-=pow(2,z);
					}
					else
					break;
				}
			}
		}
		cout<<x<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ll t;cin>>t;
	while(t--){
		ll n,x,y,m=0;cin>>n;cin>>x;
		for(ll i=1;i<n;i++){
			cin>>y;
			if(y<x)m=max(m,x-y);
			x=max(x,y);
		}
		cout<<ceil(log2(m+1))<<endl;
	}
}


#include <bits/stdc++.h>

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
ll n;
cin>>n;
scan(a,n);
ll sum=0;
ll max=a[0];
vl b;
b.pb(0);
fo(n-1){

    if(a[i]>a[i+1]){
        sum=sum+a[i+1]-a[i];
    }
  if(a[i+1]>=max){
      max=a[i+1];
      b.pb(sum);
      sum=0;
  }
}
  b.pb(sum);
        sum=0;
sort(all(b));
ll ans=0;
ll i=0;

while(1){
    if((ll)pow(2,i)-1>=abs(b[0])){
        cout<<i<<endl;
        break;
    }
    i++;

}
}
int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
 cin >> t;
  //  t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
ll n;
cin>>n;
scan(a,n);
ll sum=0;
vl b;
b.pb(0);
fo(n-1){
    if(a[i]>a[i+1]){
        sum=sum+a[i+1]-a[i];
    }
    else{
        b.pb(sum);
        sum=0;
    }
}
  b.pb(sum);
        sum=0;
sort(all(b));
ll ans=0;
ll i=0;
if(b[0]==0)cout<<0<<endl;
else{
while(1){
    if((ll)pow(2,i)-1>abs(b[0])){
        cout<<i<<endl;
        break;
    }
    i++;
}
}
}
int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
 cin >> t;
  //  t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
ll n;
cin>>n;
scan(a,n);
ll sum=0;
ll max=a[0];
vl b;
b.pb(0);
fo(n-1){

    if(a[i]>a[i+1]){
        sum=sum+a[i+1]-a[i];
    }
  if(a[i+1]>max){
      max=a[i+1];
      b.pb(sum);
      sum=0;
  }
}
  b.pb(sum);
        sum=0;
sort(all(b));
ll ans=0;
ll i=0;

while(1){
    if((ll)pow(2,i)-1>=abs(b[0])){
        cout<<i<<endl;
        break;
    }
    i++;

}
}
int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
 cin >> t;
  //  t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")

#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
//#define int long long
#define ll long long
#define endl "\n"
#define inf ULLONG_MAX
#define gcd __gcd
#define deb(x) cout << #x << " " << x << endl;
#define pr(x) cout << x << endl;

#define sz(a) ((ll)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())
#define cpres(c, val) (find(all(c), val) != (c).end())
#define dec greater<ll>()
#define sortv(x) sort(all(x))
#define revsortv(x) sort(all(x), dec)
#define com(x) ((x) * (x + 1) / 2)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bg begin()
#define ed end()
#define bs binary_search // to find if an element is present or not in Ologn time, return a boolean
#define ub upper_bound   // to find an element strictly greater than the given no.
#define lb lower_bound   // lb(v,begin(), v.end(), n) gives the iterator

#define fo(n) for (ll i = 0; i < n; i++)
#define fo1(n) for (ll i = 1; i < n; i++)
#define fo2(i, n) for (ll i = 0; i < n; i++)
#define fo3(i, a, b) for (ll i = a; i < b; i++)
#define fors(a) cin >> a[i]
#define forp(a) cout << a[i] << " "
#define prv(a, n)  \
    fo(n) forp(a); \
    cout << endl;
#define fob(i, a, b) for (ll i = (b); i >= (a); i--)

typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef unordered_map<string, ll> umsl;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;

#define scan(v, n)   \
    vl v;            \
    fo(n)            \
    {                \
        ll item;     \
        cin >> item; \
        v.pb(item);  \
    }

const ll INF = 0xFFFFFFFFFFFFFFFL;;
const ll N = 1e9 + 7;
void swap1(ll a,ll b){
    ll temp;
    temp=a;
    a=b;
    b=temp;
}
void solve()
{
ll n;
cin>>n;
scan(a,n);
ll sum=0;
vl b;
b.pb(0);
fo(n-1){
    if(a[i]>a[i+1]){
        sum=sum+a[i+1]-a[i];
    }
    else{
        b.pb(sum);
        sum=0;
    }
}
  b.pb(sum);
        sum=0;
sort(all(b));
ll ans=0;
ll i=0;
while(1){
    if((ll)pow(2,i)-1>=abs(b[0])){
        cout<<i<<endl;
        break;
    }
    i++;
}

}
int32_t main(int32_t argc, char **argv)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    freopen("inputf.txt", "r", stdin);
    freopen("outputf.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif*/

    ll t;
 cin >> t;
  //  t=1;
   while (t--)
        solve();

    cerr << endl
         << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long int t,n,i,j,h,p,f,d,g,u,z,c;
	long long int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{
			if(a[p+1]>a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		if(z==0)
		{
			cout<<0<<"\n";
		}else{

		for(f=0;f<=z;f++)
		{
			if(pow(2,f)==z)
			{
				cout<<f<<"\n";
				break;
			}else if(pow(2,f)>z)
			{
				cout<<f-1<<"\n";
				break;
			}
		}
		}
		}}

	}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long int t,n,i,j,h,p,f,d,g,u,z,c;
	long long int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{
			if(a[p+1]>a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		for(f=0;f<=z;f++)
		{
			if(pow(2,f)>=z)
			{
				cout<<f<<"\n";
				break;
			}
		}

		}}

	}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long int t,n,i,j,h,p,f,d,g,u,z,c;
	long long int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{
			if(a[p+1]>a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		for(f=0;f<=z;f++)
		{
			if(pow(2,f)==z)
			{
				cout<<f<<"\n";
				break;
			}else if(pow(2,f)>z)
			{
				cout<<f-1<<"\n";
				break;
			}
		}

		}}

	}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long int t,n,e,i,j,h,p,f,d,g,u,z,c;
	long long int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;e=0;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{
			if(a[p]==0)e++;
			if(a[p+1]>=a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		if(z==0)
		{
			cout<<0<<"\n";
		}else{

		for(f=0;f<=z;f++)
		{
			if(pow(2,f)==z)
			{
				cout<<f<<"\n";
				break;
			}else if(z<pow(2,f))
			{
				cout<<f<<"\n";
				break;
			}
		}
		}
		}}

	}


#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long int t,n,i,j,h,f,p,z,d,u,c;
	long long int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{

			if(a[p+1]>=a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		if(z==0)
		{
			cout<<0<<"\n";
		}else {
			for(f=0;f<=z;f++)
		{
			if(z==pow(2,f))
			{
			cout<<f<<"\n";break;}
			else if(z<pow(2,f)&&z%10!=0)
			{
				cout<<f<<"\n";break;
			}else if(z<pow(2,f)&&z%10==0)
			{
				cout<<f-1<<"\n";
				break;
			}
		}

}
}
}
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long int
int main()
{
    int test;
    cin>>test;
    while(test--)
    {
        int n,y;
        cin>>n;
        int a[n];
        int x;
        cin>>x;
        int diff=0;
        for(int i=1;i<n;i++)
        {
            cin>>y;
            if(x>y)
            {
                diff=max(diff,x-y);
            }
            x=max(x,y);
        }
        cout<<ceil(log2(diff+1))<<endl;

    }
}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long int t,n,i,j,h,p,f,d,g,u,z,c;
	long long int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{
			if(a[p+1]>=a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		if(z==0)
		{
			cout<<0<<"\n";
		}else{

		for(f=0;f<=z;f++)
		{
			if(pow(2,f)==z)
			{
				cout<<f<<"\n";
				break;
			}else if(pow(2,f)>z)
			{
				cout<<f-1<<"\n";
				break;
			}
		}
		}
		}}

	}


#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;

int main()

{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int t,n,i,j,h,p,f,d,g,u,z,c;int a[100005];

	cin>>t;for(i=0;i<t;i++)
	{
		cin>>n;c=0;h=-1;
		for(j=0;j<n;j++)
		cin>>a[j];

		for(p=0;p<n-1;p++)
		{
			if(a[p+1]>a[p])
			c++;
			if(c!=p+1)
			{
				h=p;
				break;
			}
		}if(h==-1){
			cout<<0<<"\n";
		}
		else {

		u=a[h+1];
		for(d=h+1;d<n;d++)
		{
			if(u>a[d])u=a[d];
		}
		z=(a[h]-u)*2;
		for(f=0;f<=z;f++)
		{
			if(pow(2,f)>=z)
			{
				cout<<f<<"\n";
				break;
			}
		}

		}}

	}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		set<int> s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			s.insert(a[i]);
		}

		int d = 0;
		for (int i = 0; i < n; i++) {
			s.erase(a[i]);
			if (s.size() > 0) {
				set<int>::iterator itr = s.begin();
				if (*itr < a[i])
					d = max(d, a[i] - *itr);
			}
		}
		if (d == 0) {
			cout << 0 << endl;
			continue;

		}
		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int sc = 1;
		while (c != d) {
			c = c | c << 1;
			sc++;
		}

		cout << sc << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<ll> a(n);
		multiset<ll> s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			s.insert(a[i]);
		}
		set<ll>::iterator itr;
		ll d = 0;
		for (int i = 0; i < n - 1; i++) {
			itr = s.find(a[i]);
			s.erase(itr);
			itr = s.begin();
			if (*itr < a[i])
				d = max(d, a[i] - *itr);
		}

		if (d == 0) {
			cout << 0 << endl;
			continue;

		}
		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		d = d | d >> 16;
		ll c = 1;
		ll sc = 1;
		while (c != d) {
			c = c | c << 1;
			sc++;
		}

		cout << sc << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		for (int i = 0; i < n; i++) {
			cin >> a[i];

		}
		bool p = true;

		for (int i = 1; i < n; i++) {
			if (a[i] < a[i - 1]) {
				p = false;
				ma = max(ma, a[i - 1]);
				mi = min(mi, a[i - 1]);
			}
			if (!p) {
				if (i != n - 1)
					ma = max(ma, a[i]);
				mi = min(mi, a[i]);
			}
		}
		if (p) {
			cout << 0 << endl;
			continue;
		}
		int d = ma - mi;

		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int s = 1;
		while (c != d) {
			c = c | c << 1;
			s++;
		}

		cout << s << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		for (int i = 0; i < n; i++) {
			cin >> a[i];

		}
		bool p = true;

		for (int i = 1; i < n; i++) {
			if (a[i] < a[i - 1]) {
				p = false;
				ma = max(ma, a[i - 1]);
				mi = min(mi, a[i - 1]);
			}
			if (!p) {
				ma = max(ma, a[i]);
				mi = min(mi, a[i]);
			}
		}
		if (p) {
			cout << 0 << endl;
			continue;
		}
		int d = ma - mi;

		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int s = 1;
		while (c != d) {
			c = c | c << 1;
			s++;
		}

		cout << s << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		multiset<int> s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			s.insert(a[i]);
		}
		set<int>::iterator itr;
		int d = 0;
		for (int i = 0; i < n - 1; i++) {
			itr = s.find(a[i]);
			s.erase(itr);
			itr = s.begin();
			if (*itr < a[i])
				d = max(d, a[i] - *itr);
		}

		if (d == 0) {
			cout << 0 << endl;
			continue;

		}
		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int sc = 1;
		while (c != d) {
			c = c | c << 1;
			sc++;
		}

		cout << sc << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);

		for (int i = 0; i < n; i++) {
			cin >> a[i];

		}
		vector<int> diff;
		for (int i = 1; i < n; i++) {
			int d = a[i - 1] - a[i];
			if (d > 0)
				diff.push_back(d);
		}
		int s = 0;
		int b = 1;
		sort(diff.begin(), diff.end());
		int y = diff.size();
		int i = 0;
		while (i < y) {
			diff[i] = diff[i] - b;
			s++;
			b *= 2;
			if (diff[i] <= 0)
				i++;
		}
		cout << s << endl;

	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		for (int i = 0; i < n; i++) {
			cin >> a[i];

		}
		bool p = true;

		for (int i = 1; i < n; i++) {
			if (a[i] < a[i - 1]) {
				p = false;
				ma = max(ma, a[i - 1]);
				mi = min(mi, a[i - 1]);
			}
			if (!p) {
				ma = max(ma, a[i]);
				mi = min(mi, a[i]);
			}
		}
		if (p) {
			cout << 0 << endl;
			continue;
		}
		int d = ma - mi;
		int b = 1, s = 1;
		while (b <= d) {
			b *= 2;
			s++;
		}
		s--;
		cout << s << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		set<int> s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			s.insert(a[i]);
		}

		int d = 0;
		for (int i = 0; i < n; i++) {
			s.erase(a[i]);
			set<int>::iterator it = s.begin();
			if (*it < a[i])
				d = max(d, a[i] - *it);
		}
		if (d == 0) {
			cout << 0 << endl;
			continue;

		}
		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int sc = 1;
		while (c != d) {
			c = c | c << 1;
			sc++;
		}

		cout << sc << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		set<int> s;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			s.insert(a[i]);
		}

		int d = 0;
		for (int i = 0; i < n; i++) {
			s.erase(a[i]);
			set<int>::iterator itr = s.begin();
			if (*itr < a[i])
				d = max(d, a[i] - *itr);
		}
		if (d == 0) {
			cout << 0 << endl;
			continue;

		}
		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int sc = 1;
		while (c != d) {
			c = c | c << 1;
			sc++;
		}

		cout << sc << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> a(n);
		int ma = INT32_MIN;
		int mi = INT32_MAX;
		for (int i = 0; i < n; i++) {
			cin >> a[i];

		}
		bool p = true;
		int d = 0;
		for (int i = 1; i < n; i++)
		{
			if (a[i] < a[i - 1]) {
				int j = i - 1;
				while (i < n && a[i] < a[i - 1])
					i++;
				i--;
				d = max(d, a[j] - a[i]);
			}
		}

		if (d == 0) {
			cout << 0 << endl;
			continue;

		}
		d = d | d >> 1;
		d = d | d >> 2;
		d = d | d >> 4;
		d = d | d >> 8;
		int c = 1;
		int s = 1;
		while (c != d) {
			c = c | c << 1;
			s++;
		}

		cout << s << endl;
	}
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=100001;
typedef  long long int ll;
int main()
{
    int t;
   scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int a[maxn];
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        int x=a[1];
        int k=0;
        for(int i=2; i<=n; i++)
        {
            x=max(x,a[i]);
            if(a[i]<x)
                k=max(k,x-a[i]);
        }
        if(k==0)
        {
            printf("0\n");
            continue;
        }
        ll i=0;
        ll p=0;
        for(i=1;; i++)
        {
            if(i==1)
                p=1;
            else
                p=p*2;
            if(p>=k)
                break;
        }
        printf("%lld\n",i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=100001;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[maxn];
        for(int i=1; i<=n; i++)
            cin>>a[i];
        int x=a[1];
        int k=0;
        for(int i=2; i<=n; i++)
        {
            x=max(x,a[i]);
            if(a[i]<x)
                k=max(k,x-a[i]);
        }
        if(k==0)
        {
            printf("0\n");
            continue;
        }
        int i=0;
        int p=0;
        for(i=1;; i++)
        {
            if(i==1)
                p=1;
            else
                p=p*2;
            if(p>=k)
                break;
        }
        printf("%d\n",i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=100001;
typedef long long ll;
int main()
{
    int t;
   scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int a[maxn];
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        int x=a[1];
        ll k=0;
        for(int i=2; i<=n; i++)
        {
            x=max(x,a[i]);
            if(a[i]<x)
                k=max(k,x-a[i]);
        }
        if(k==0)
        {
            printf("0\n");
            continue;
        }
        ll i=0;
        ll p=0;
        for(i=1;; i++)
        {
            if(i==1)
                p=1;
            else
                p=p*2;
            if(p>=k)
                break;
        }
        printf("%d\n",i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=100001;
int main()
{
    int t;
   scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int a[maxn];
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        int x=a[1];
        int k=0;
        for(int i=2; i<=n; i++)
        {
            x=max(x,a[i]);
            if(a[i]<x)
                k=max(k,x-a[i]);
        }
        if(k==0)
        {
            printf("0\n");
            continue;
        }
        int i=0;
        int p=0;
        for(i=1;; i++)
        {
            if(i==1)
                p=1;
            else
                p=p*2;
            if(p>=k)
                break;
        }
        printf("%d\n",i);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn=100001;
typedef  long long  ll;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        int a[maxn];
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        int x=a[1];
        int k=0;
        for(int i=2; i<=n; i++)
        {
            x=max(x,a[i]);
            if(a[i]<x)
                k=max(k,x-a[i]);
        }
        if(k==0)
        {
            printf("0\n");
            continue;
        }
        int i=0;
        ll p=0;
        ll ans=0;
        for(i=1;; i++)
        {
            if(i==1)
                p=1;
            else
                p=p*2;
            ans+=p;
            if(ans>=k)
                break;
        }
        printf("%lld\n",i);
    }
    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

int main() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<int> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        int time = 0;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                ++time;
            }
        }

        while (!solved) {
            int max = values[0];
            bool checking = true;

            for (int i = 1; i < n; ++i) {
                if (values[i] < max) {
                    values[i] += (1 << (time - 1));

                    if (values[i] < max) {
                        checking = false;
                    }
                } else {
                    max = values[i];
                }
            }

            if (checking) {
                solved = true;
            } else {
                ++time;
            }
        }

        results.push_back(time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

int main() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<int> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        int time = 0;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                ++time;
                break;
            }
        }

        while (!solved) {
            int max = values[0];
            bool checking = true;

            for (int i = 1; i < n; ++i) {
                if (values[i] < max) {
                    values[i] += (1 << (time - 1));

                    if (values[i] < max) {
                        checking = false;
                    }
                } else {
                    max = values[i];
                }
            }

            if (checking) {
                solved = true;
            } else {
                ++time;
            }

        }

        results.push_back(time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

int main1() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        int time = 0;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                ++time;
                break;
            }
        }

        while (!solved) {
            long long max = values[0];
            bool checking = true;

            for (int i = 1; i < n; ++i) {
                if (values[i] < max) {
                    values[i] += (1 << (time - 1));

                    if (values[i] < max) {
                        checking = false;
                    }
                } else {
                    max = values[i];
                }
            }

            if (checking) {
                solved = true;
            } else {
                ++time;
            }

        }

        results.push_back(time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}

int main() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                break;
            }
        }

        if (solved) {
            results.push_back(0);
            continue;
        }

        long long max = values[0];
        int max_time = 0;
        for (int i = 1; i < n; ++i) {
            long long value = values[i];
            if (value < max) {
                int curr_time = 0;
                while(value < max) {
                    ++curr_time;
                    value += (1 << (curr_time - 1));
                }

                if (curr_time > max_time) {
                    max_time = curr_time;
                }
            }

            max = value;
        }

        results.push_back(max_time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

int main1() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        int time = 0;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                ++time;
                break;
            }
        }

        while (!solved) {
            long long max = values[0];
            bool checking = true;

            for (int i = 1; i < n; ++i) {
                if (values[i] < max) {
                    values[i] += (1 << (time - 1));

                    if (values[i] < max) {
                        checking = false;
                    }
                } else {
                    max = values[i];
                }
            }

            if (checking) {
                solved = true;
            } else {
                ++time;
            }

        }

        results.push_back(time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}

int main() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                break;
            }
        }

        if (solved) {
            results.push_back(0);
            continue;
        }

        long long max = values[0];
        int max_time = 0;
        for (int i = 1; i < n; ++i) {
            long long value = values[i];
            if (value < max) {
                int curr_time = 0;
                long long power = 1;
                while(value < max) {
                    ++curr_time;
                    value += power;
                    power *= 2;
                }

                if (curr_time > max_time) {
                    max_time = curr_time;
                }
            }

            max = value;
        }

        results.push_back(max_time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

int main1() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        int time = 0;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                ++time;
                break;
            }
        }

        while (!solved) {
            long long max = values[0];
            bool checking = true;

            for (int i = 1; i < n; ++i) {
                if (values[i] < max) {
                    values[i] += (1 << (time - 1));

                    if (values[i] < max) {
                        checking = false;
                    }
                } else {
                    max = values[i];
                }
            }

            if (checking) {
                solved = true;
            } else {
                ++time;
            }

        }

        results.push_back(time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}

int main() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                break;
            }
        }

        if (solved) {
            results.push_back(0);
            continue;
        }

        long long max = values[0];
        int max_time = 0;
        for (int i = 1; i < n; ++i) {
            long long value = values[i];
            if (value < max) {
                int curr_time = 1;
                long long diff = max - value;
                long long power = 1;
                while(power < diff) {
                    ++curr_time;
                    power *= 2;
                }

                if (power > diff) {
                    --curr_time;
                }

                if (curr_time > max_time) {
                    max_time = curr_time;
                }
            } else {
                max = value;
            }
        }

        results.push_back(max_time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>

int main() {

    int tests;
    std::cin >> tests;
    std::vector<int> results;
    for (int test = 0; test < tests; ++test) {
        int n;
        std::cin >> n;
        std::vector<long long> values(n);
        for (int i = 0; i < n; ++i) {
            std::cin >> values[i];
        }

        bool solved = true;
        int time = 0;
        for (int i = 1; i < n; ++i) {
            if (values[i - 1] > values[i]) {
                solved = false;
                ++time;
                break;
            }
        }

        while (!solved) {
            long long max = values[0];
            bool checking = true;

            for (int i = 1; i < n; ++i) {
                if (values[i] < max) {
                    values[i] += (1 << (time - 1));

                    if (values[i] < max) {
                        checking = false;
                    }
                } else {
                    max = values[i];
                }
            }

            if (checking) {
                solved = true;
            } else {
                ++time;
            }

        }

        results.push_back(time);
    }

    for (int i = 0; i < tests; ++i) {
        std::cout << results[i] << std::endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

int main()
{
   FAST/**/

   ll powa[64];
   powa[0] = 1;
   for(ll i=1;i<64;i++)
        powa[i] = powa[i-1]*2;

   ll t;
   cin>>t;

   while(t--)
   {
       ll n;
       cin>>n;

       ll arr[n];
       rep(n)
            cin>>arr[i];
       ll sum = 0;
       ll x = 0;
       rep(n)
       {
           if(i == 0)
                continue;
           if(arr[i]+sum<arr[i-1]){
           while(arr[i]+sum<arr[i-1])
           {
               sum+=powa[x++];
               continue;
           }
           arr[i]+=sum;
           }
           else
           {
               for(ll j=0;j<x;j++)
               {
                   if(powa[j]+arr[i]<=arr[i-1])
                        arr[i]+=powa[j];
               }
           }
       }

       cout<<x<<"\n";

   }

   return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

int main()
{
   FAST/**/

   ll powa[64];
   powa[0] = 1;
   for(ll i=1;i<64;i++)
        powa[i] = powa[i-1]*2;

   ll t;
   cin>>t;

   while(t--)
   {
       ll n;
       cin>>n;

       ll arr[n];
       rep(n)
            cin>>arr[i];
       ll sum = 0;
       ll x = 0;
       rep(n)
       {
           if(i == 0)
                continue;
           if(arr[i]+sum<arr[i-1]){
           while(arr[i]+sum<arr[i-1])
           {
               sum+=powa[x++];
               continue;
           }
           arr[i]+=sum;
           }
           else
           {
               for(ll j=0;j<x;j++)
               {
                   if((powa[j]&sum) == 0)
                        continue;
                   if(powa[j]+arr[i]<arr[i-1])
                        arr[i]+=powa[j];
               }
           }
       }

       cout<<x<<"\n";

   }

   return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

int main()
{
   FAST/**/

   ll powa[64];
   powa[0] = 1;
   for(ll i=1;i<64;i++)
        powa[i] = powa[i-1]*2;

   ll t;
   cin>>t;

   while(t--)
   {
       ll n;
       cin>>n;

       ll arr[n];
       rep(n)
            cin>>arr[i];
       ll sum = 0;
       ll x = 0;
       rep(n)
       {
           if(i == 0)
                continue;
           while(arr[i]+sum<arr[i-1])
           {
               sum+=powa[x++];
               continue;
           }
           arr[i]+=sum;
       }

       cout<<x<<"\n";

   }

   return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

int main()
{
   FAST/**/

   ll powa[64];
   powa[0] = 1;
   for(ll i=1;i<64;i++)
        powa[i] = powa[i-1]*2;

   ll t;
   cin>>t;

   while(t--)
   {
       ll n;
       cin>>n;

       ll arr[n];
       rep(n)
            cin>>arr[i];
       ll sum = 0;
       ll x = 0;
       rep(n)
       {
           if(i == 0)
                continue;
           if(arr[i]+sum>=arr[i-1])
           {
               for(ll j=x-1;j>-1;j--)
               {
                   if(powa[j]+arr[i]<=arr[i-1])
                        arr[i]+=powa[j];
               }
           }
           else
           {
               while(arr[i]+sum<arr[i-1])
               {
                   sum+=powa[x++];
                   continue;
               }
               for(ll j=x-1;j>-1;j--)
               {
                   if(powa[j]+arr[i]<=arr[i-1])
                        arr[i]+=powa[j];
               }
           }
       }

       cout<<x<<"\n";

   }

   return 0;
}


#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

int main()
{
   FAST/**/

   ll powa[64];
   powa[0] = 1;
   for(ll i=1;i<64;i++)
        powa[i] = powa[i-1]*2;

   ll t;
   cin>>t;

   while(t--)
   {
       ll n;
       cin>>n;

       ll arr[n];
       rep(n)
            cin>>arr[i];
       ll sum = 0;
       ll x = 0;
       rep(n)
       {
           if(i == 0)
                continue;
           if(arr[i]+sum>=arr[i-1])
           {
               for(ll j=0;j<x;j++)
               {
                   if(powa[j]+arr[i]<=arr[i-1])
                        arr[i]+=powa[j];
               }
           }
           else
           {
               while(arr[i]+sum<arr[i-1])
               {
                   sum+=powa[x++];
                   continue;
               }
               for(ll j=0;j<x;j++)
               {
                   if(powa[j]+arr[i]<=arr[i-1])
                        arr[i]+=powa[j];
               }
           }
       }

       cout<<x<<"\n";

   }

   return 0;
}


using namespace std;

vector<long long>v;

long long bala(vector<long long>v4,long long p)
{
    long long s,z=0,lol;
    vector<long long>v3;

    for(long long x=0; x<p-1; x++)
    {
        if(v4[x]>v4[x+1])
        {
            s=v4[x]-v4[x+1];
            v3.push_back(s);
            v4[x+1]=v4[x+1]+s;

        }

    }

    lol=v3.size();
    sort(v3.begin(),v3.end());
    if(lol==0)
    {
        return 0;
    }
    else
    {
        return v3[lol-1];
    }

  for(int i=0;i<p;i++)
  {
      cout<<v4[i]<<endl;
  }

}

long long a,b=0,c,d,e,i;

int main()
{
    cin>>a;
    while(b<a)
    {
        cin>>c;
        v.clear();
        for(i=0; i<c; i++)
        {
            cin>>d;
            v.push_back(d);
        }
        e=bala(v,c);
        if(e==0)
        {
            cout<<'0'<<endl;
        }
        if((floor(log2(e))==ceil(log2(e))) && (e!=0))
        {
             cout<<log2(e)+1<<endl;
        }
        else if((floor(log2(e))!=ceil(log2(e))) && (e!=0))
        {
            cout<<ceil(log2(e))<<endl;
        }
        b++;

    }

}


#include<bits/stdc++.h>

using namespace std;

long long o,d,b,p,q,s,k,m;

vector<long long>v;
vector<long long>::iterator vit;

void solve(long long c )
{
    long long a[c];
    for(long long  i=0; i<c; i++)
    {
        cin>>o;
        a[i]=o;
        if(i>0)
        {
            b=a[i-1];
            if(b>a[i])
            {
                d=b-a[i];

                if(ceil(log2(d))==floor(log2(d)))
                {
                    k=log2(d)+1;
                    m=a[i-1];
                    a[i]=m+d;
                    v.push_back(k);
                }
                else

                {
                    m=a[i-1];
                    p=ceil(log2(d));
                    a[i]=m+p;

                    v.push_back(p);
                }

            }
            else
            {
                s++;
            }
        }

    }

    if(s==c)
    {
        cout<<'0'<<endl;
    }
    else

    {
        sort(v.begin(),v.end());
        q=v.size();
        cout<<v[q-1]<<endl;
    }

}

int main()
{
    long long w,x=0,l;
    cin>>w;
    while(x<w)
    {
        cin>>l;
        solve(l);
        x++;
    }
}


#include<bits/stdc++.h>

using namespace std;

vector<long long>v;
vector<long long>::iterator vit;

vector<long long>v1;
vector<long long>::iterator v1it;

long long a,b=0,c,d,e,f,g,h,i,j,max_index,max_value;

int main()
{
    cin>>a;
    while(b<a)
    {
        cin>>c;
        v.clear();
        v1.clear();
        f=0;
        for(i=0;i<c;i++)
        {
            cin>>d;
            v.push_back(d);
            v1.push_back(d);

        }
        max_index=max_element(v.begin(),v.end())-v.begin();
        max_value=*max_element(v.begin(),v.end());

        sort(v1.begin()+max_index,v1.end());
        f=v1[c-1]-v1[max_index];

        if(f==0)
        {
            cout<<f<<endl;
        }
        if((ceil(log2(f))==floor(log2(f))) && f!=0)
        {
            cout<<f<<endl;
        }
        else if((ceil(log2(f)))!=floor(log2(f)) && f!=0)
        {
            cout<<ceil(log2(f))<<endl;
        }

        b++;
    }
}