#include<bits/stdc++.h>
#define bug(a) (cout<<'*'<<a<<endl)
#define bugg(a,b) (cout<<'*'<<a<<' '<<b<<endl)
#define buggg(a,b,c) (cout<<'*'<<a<<' '<<b<<' '<<c<<endl)
#define pn (cout<<endl)
typedef long long ll;
using namespace std;
ll ar[100002];
int main()
{
	ll t, i, j, n, num1, num2, t1, t2, minn = 999999999, dif, ans, maxx;
	ll sum, summ;
	scanf("%lld", &t);
	while (t--)
	{
		maxx = -1, minn = 999999999, t1 = -1, sum = 1, summ = 1;
		scanf("%lld", &n);
		for (i = 1; i <= n; i++)
		{
			scanf("%lld", &ar[i]);
		}
		maxx = -1;
		dif = 0;
		for (i = 1; i <= n; i++)
		{
			dif = max(dif, maxx - ar[i]);
			maxx = max(maxx, ar[i]);
		}
		if (maxx == -1)
		{
			printf("0\n");
			continue;
		};
		maxx = dif;
		for (i = 1; summ < maxx; i++)
		{
			sum *= 2;
			summ += sum;
			//bug(sum);
		}
		printf("%lld\n", i);
	}
	return 0;
}


#include<bits/stdc++.h>
#define bug(a) (cout<<'*'<<a<<endl)
#define bugg(a,b) (cout<<'*'<<a<<' '<<b<<endl)
#define buggg(a,b,c) (cout<<'*'<<a<<' '<<b<<' '<<c<<endl)
#define pn (cout<<endl)
typedef long long ll;
using namespace std;
ll ar[100002];
int main()
{
	ll t, i, j, n, num1, num2, t1, t2, minn = 999999999, dif, ans, maxx;
	ll sum, summ;
	scanf("%lld", &t);
	while (t--)
	{
		maxx = -1, minn = 999999999, t1 = -1, sum = 1, summ = 1;
		scanf("%lld", &n);
		for (i = 1; i <= n; i++)
		{
			scanf("%lld", &ar[i]);
		}
		maxx = -1;
		dif = 0;
		for (i = 1; i <= n; i++)
		{
			dif = max(dif, maxx - ar[i]);
			maxx = max(maxx, ar[i]);
		}
		if (dif == 0)
		{
			printf("0\n");
			continue;
		};
		maxx = dif;
		for (i = 1; summ < maxx; i++)
		{
			sum *= 2;
			summ += sum;
			//bug(sum);
		}
		printf("%lld\n", i);
	}
	return 0;
}


#include<bits/stdc++.h>
#define bug(a) (cout<<'*'<<a<<endl)
#define bugg(a,b) (cout<<'*'<<a<<' '<<b<<endl)
#define buggg(a,b,c) (cout<<'*'<<a<<' '<<b<<' '<<c<<endl)
#define pn (cout<<endl)
typedef long long ll;
using namespace std;
int ar[100002];
int main()
{
	int t, i, j, n, num1, num2, t1, t2, minn = 999999999, dif, ans, maxx;
	ll sum, summ;
	scanf("%d", &t);
	while (t--)
	{
		maxx = -1, minn = 999999999, t1 = -1, sum = 1, summ = 1;
		scanf("%d", &n);
		for (i = 1; i <= n; i++)
		{
			scanf("%d", &ar[i]);
		}
		for (i = 1; i < n; i++)
		{
			for (j = i + 1; j <= n; j++)
			{
				if (ar[j] >= ar[i])
					continue;
				maxx = max(maxx,ar[i] - ar[j]);
			}
		}
		if (maxx == -1)
		{
			printf("0\n");
			continue;
		};
		for (i = 1; summ < maxx; i++)
		{
			sum *= 2;
			summ += sum;
			//bug(sum);
		}
		printf("%d\n", i);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

struct region{
    int l, r;
};

int T;
int N;
int a[100010];
int b[100010];
vector<region> dec;
int ans = 0;
// find optimal state of array by looping through and making sure every node is greater than previous,
// and check how many turns are required to get it done.

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){ // if previous is larger, which means we need to increase current
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%d", &a[i]);
        }
        solve();
        int maxx = 1;
        int cnt = 1;
        while(maxx < ans){
            maxx *= 2;
            cnt += 1;
        }
        if (ans == 0) printf("0\n");
        else printf("%d\n", cnt);

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

int T;
int N;
ll a[100010];
ll b[100010];
ll ans = 0;

void solve(){
   /* b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }*/
    for(int i=1;i<N;i++)
    {
        if(a[i]>=a[i-1]) continue;
        else
        {
            ans=max(ans,a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
       // memset(b, 0, sizeof(b));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%lld", &a[i]);
        }
        solve();
       /* ll maxx = 1;
        ll summ = maxx;
        int cnt = 1;
        while(summ < ans){
            maxx = maxx*2;
            summ += maxx;
            cnt += 1;
        }*/
        int cnt=0;
        int maxx=ans;
        while(maxx)
        {
            cnt++;
            maxx>>=1;
        }
        if (ans == 0) cout << 0 << endl;
        else cout << cnt << endl;

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

struct region{
    int l, r;
};

int T;
int N;
int a[100010];
int b[100010];
vector<region> dec;
int ans = 0;
// find optimal state of array by looping through and making sure every node is greater than previous,
// and check how many turns are required to get it done.

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){ // if previous is larger, which means we need to increase current
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%d", &a[i]);
        }
        solve();
        ll maxx = 1;
        int cnt = 1;
        while(maxx < ans){
            maxx = maxx*2;
            cnt += 1;
        }
        if (ans == 0) printf("0\n");
        else printf("%d\n", cnt);

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

int T;
int N;
ll a[100010];
ll b[100010];
ll ans = 0;

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%lld", &a[i]);
        }
        solve();
       /* ll maxx = 1;
        ll summ = maxx;
        int cnt = 1;
        while(summ < ans){
            maxx = maxx*2;
            summ += maxx;
            cnt += 1;
        }*/
        int cnt=0;
        int maxx=ans;
        while(maxx)
        {
            cnt++;
            maxx>>=1;
        }
        if (ans == 0) cout << 0 << endl;
        else cout << cnt << endl;

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

struct region{
    int l, r;
};

int T;
int N;
ll a[100010];
ll b[100010];
vector<region> dec;
ll ans = 0;
// find optimal state of array by looping through and making sure every node is greater than previous,
// and check how many turns are required to get it done.

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){ // if previous is larger, which means we need to increase current
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%lld", &a[i]);
        }
        solve();
        ll maxx = 1;
        int cnt = 1;
        while(maxx <= ans){
            maxx = maxx*2;
            cnt += 1;
        }
        if (ans == 0) cout << 0 << endl;
        else cout << cnt-1 << endl;

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

int T;
int N;
ll a[100010];
ll b[100010];
ll ans = 0;

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%lld", &a[i]);
        }
        solve();
       /* ll maxx = 1;
        ll summ = maxx;
        int cnt = 1;
        while(summ < ans){
            maxx = maxx*2;
            summ += maxx;
            cnt += 1;
        }*/
        int cnt=0;
        int maxx=ans;
        while(maxx)
        {
            cnt++;
            maxx>>=1;
        }
        if (ans == 0) cout << 0 << endl;
        else cout << cnt << endl;

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

int T;
int N;
ll a[100010];
ll b[100010];
ll ans = 0;

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%lld", &a[i]);
        }
        solve();
        ll maxx = 1;
        ll summ = maxx;
        int cnt = 1;
        while(summ < ans){
            maxx = maxx*2;
            summ += maxx;
            cnt += 1;
        }
        if (ans == 0) cout << 0 << endl;
        else cout << cnt << endl;

    }

    return 0;
}


#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <fstream>
#include <stdio.h>
#include <map>
#include <ctime>
#define ll long long
#define TEST cout << "test" << endl;
using namespace std;

struct region{
    int l, r;
};

int T;
int N;
ll a[100010];
ll b[100010];
vector<region> dec;
ll ans = 0;

// find optimal state of array by looping through and making sure every node is greater than previous,
// and check how many turns are required to get it done.

void solve(){
    b[0] = a[0];
    for (int i = 1; i < N; i++){
        if (a[i] < a[i-1]){ // if previous is larger, which means we need to increase current
            b[i] = max(a[i-1], b[i-1]);
        }else{
            b[i] = a[i];
        }
    }
    for (int i = 0; i < N; i++){
        ans = max(ans, b[i]-a[i]);
    }
}

int main(){
    scanf("%d", &T);
    while(T--){
        ans = 0;
        memset(a, 0, sizeof(a));
        scanf("%d", &N);
        for (int i = 0; i < N; i++){
            scanf("%lld", &a[i]);
        }
        solve();
        ll maxx = 1;
        ll summ = maxx;
        int cnt = 1;
        while(summ < ans){
            maxx = maxx*2;
            summ += maxx;
            cnt += 1;
        }
        if (ans == 0) cout << 0 << endl;
        else cout << cnt << endl;

    }

    return 0;
}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    /*ll cng,a=2000000000;
    cng=log2(a+1);if(pow(2,cng)!= a+1)cng++;
    cout<<cng;*/
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll t;cin>>t;
    while(t--){
        ll n;cin>>n;
        ll cng=0,prev=0,now=0,mn=INT_MAX,mx=INT_MIN, mxd=0;
        cin>>prev;
        for(int i=1;i<n;i++){
            cin>>now;
            if(now<prev){cng++;}
            if(!(i-1) && cng){mx=prev;mn=prev;}
            if(cng){
            mx=max(mx,now);
            mn=min(mn,now);}
            prev=now;
        }
        if(cng){mxd=mx-mn;}
        if(mxd<= pow(2,cng)-1){cout<<cng;}
        else{
            cng=log2(mxd+1);if(pow(2,cng)!= mxd+1)cng++;
            cout<<cng;
        }cout<<"\n";

    }

}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll t;cin>>t;
    while(t--){
        ll n;cin>>n;
        int cng=0,prev=0,now=0,mxd=INT_MIN;
        cin>>prev;
        for(int i=1;i<n;i++){
            cin>>now;
            if(now<prev){cng++;mxd=max(mxd,prev-now);}
            prev=now;
        }
        if(mxd<= pow(2,cng)-1){cout<<cng;}
        else{
            int pwr=pow(2,cng),cnt=cng;
            while(mxd+1 >pwr){
                pwr*=2;cnt++;
            }cout<<cnt;
        }cout<<"\n";

    }

}


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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
const ll INF=1e17L+5;const int mod=1e9+7;

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

    CASE(t){
        int n;cin>>n;
        int l,w,mx=INT_MIN,f=0,mn=INT_MAX;cin>>l;
        f(i,1,n){
            cin>>w;
            if(l>w){
                mx=max(l,mx);mn=min(mn,w);f=1;
            }
            l=w;
        }
        //cout<<mx<<" mx mn "<<mn<<endl;
        if(!f)cs(0);
        else{
            int res=log2(mx-mn+1);
            if(power(2,res)!=mx-mn+1)res++;
            cs(res);
        }
    }

  }


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll t;cin>>t;
    while(t--){
        ll n;cin>>n;
        ll mxd=0,mx=INT_MIN;
        for(int i=0;i<n;i++){
            ll tmp;cin>>tmp;
            mx=max(mx,tmp);
            mxd=max(mxd,mx-tmp);

        }
        ll cng=0;
        if(mxd==0){cout<<cng;}
        else{
            cng=log2(mxd+1);if(pow(2,cng)!= mxd+1)cng++;
            cout<<cng;
        }cout<<"\n";

    }

}


#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll t;cin>>t;
    while(t--){
        ll n;cin>>n;
        ll cng=0,prev=0,now=0,mxd=INT_MIN;
        cin>>prev;
        for(int i=1;i<n;i++){
            cin>>now;
            if(now<prev){cng++;mxd=max(mxd,prev-now);}
            prev=now;
        }
        if(mxd<= pow(2,cng)-1){cout<<cng;}
        else{
            cng=log2(mxd+1);if(pow(2,cng)!= mxd+1)cng++;
            cout<<cng;
        }cout<<"\n";

    }

}


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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
const ll INF=1e17L+5;const int mod=1e9+7;

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

    CASE(t){
        int n;cin>>n;
        int l,w,mx=INT_MIN,f=0,mn=INT_MAX;cin>>l;
        f(i,1,n){
            cin>>w;
            if(l>w){
                mx=max(l,mx);mn=min(mn,w);f=1;
            }
            l=w;
        }
        //cout<<mx<<" mx mn "<<mn<<endl;
        if(!f)cs(0);
        else{
            int res=log2(mx-mn+1);
            if(pow(2,res)!=mx-mn+1)res++;
            cs(res);
        }
    }

  }


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

#define ll long long
#define forr(i,n) for(ll i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

ll power(ll a,ll b){ll r=1;while(b--)r*=a;return r;}
const ll INF=1e17L+5;const int mod=1e9+7;

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

    CASE(t){
        int n;cin>>n;
        int mx=INT_MIN,mxd=0;
        f(i,0,n){
            int w; cin>>w;
            mx=max(mx,w);
            mxd=max(mxd,mx-w);
        }
        //cout<<mx<<" mx mn "<<mn<<endl;
        if(!mxd)cs(0);
        else{
            int res=log2(mxd+1);
            if(power(2,res)!=mxd+1)res++;
            cs(res);
        }
    }

  }


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        int s;
        cin >> s;
        vector<int> init(0);
        vector<int> even(0);
        vector<int> odd(0);
        for (int j = 0; j < 2 * s; j++)
        {
            int element;
            cin >> element;
            init.push_back(element);
        }
        for (int k = 0; k < 2 * s; k++)
        {
            if (init[k] % 2 == 0)
            {
                even.push_back(k);
            }
            else
            {
                odd.push_back(k);
            }
        }
        int start_index1 = 0, start_index2 = 0;
        if (even.size() % 2 == 0)
        {
            if (even.size() >= odd.size())
            {
                start_index1 = 2;
            }
            else
            {
                start_index2 = 2;
            }
        }
        else
        {
            start_index1 = start_index2 = 1;
        }
        for (int m = start_index1; m < even.size(); m += 2)
        {
            cout << even[m] << " " << even[m + 1] << endl;
        }
        for (int q = start_index2; q < odd.size(); q += 2)
        {
            cout << odd[q] << " " << odd[q + 1] << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int logarithm2(long int n)
{
    int k = 0;
    while (n > 0)
    {
        n /= 2;
        k++;
    }
    return k;
}
int differences(long int n)
{
    long int a[n];
    for (int x = 0; x < n; x++)
    {
        cin >> a[x];
    }
    long int max_dif = 0;
    for (long int j = 1; j < n; j++)
    {
        for (long int k = 0; k < j; k++)
        {
            max_dif = max(max_dif, a[k] - a[j]);
        }
    }

    return logarithm2(max_dif);
}
int main()
{
    int t;
    cin >> t;
    for (int y = 0; y < t; y++)
    {
        long int n;
        cin >> n;
        cout << differences(n) << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int logarithm2(long int n)
{
    int k = 0;
    while (n >= 1)
    {
        n /= 2;
        k++;
    }
    return k;
}
int differences(long int n)
{
    long int a[n];
    long int max_dif = 0;
    for (int x = 0; x < n; x++)
    {
        cin >> a[x];
    }
        long int ans2 = a[0];
    for (int i = 0; i < n; i++){
        ans2 = max(ans2, a[i]);
        max_dif = max(max_dif, ans2 - a[i]);
    }

    return logarithm2(max_dif);
}
int main()
{
    int t;
    cin >> t;
    for (int y = 0; y < t; y++)
    {
        long int n;
        cin >> n;
        cout << differences(n) << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int logarithm2(long int n)
{
    int k = 0;
    while (n > 0)
    {
        n /= 2;
        k++;
    }
    return k;
}
int differences(long int n)
{
    long int a[n];
    long int max_dif = 0;
    long int val = 0;
    for (int x = 0; x < n; x++)
    {
        cin >> a[x];
        long int ans1 = a[0];
        ans1 = max(ans1, a[x]);
        max_dif = max(max_dif, ans1 - a[x]);

    }

    return logarithm2(max_dif);
}
int main()
{
    int t;
    cin >> t;
    for (int y = 0; y < t; y++)
    {
        long int n;
        cin >> n;
        cout << differences(n) << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int differences(long int n)
{
    long int a[n];
    for (int x = 0; x < n; x++)
    {
        cin >> a[x];
    }
    long int max_dif = 0;
    for (long int j = 1; j < n; j++)
    {
        for (long int k = 0; k < j; k++)
        {
            max_dif = max(max_dif, a[k] - a[j]);
        }
    }
    if (max_dif == 0)
    {
        return 0;
    }
    return (int)log2(max_dif) + 1;
}
int main()
{
    int t;
    cin >> t;
    for (int y = 0; y < t; y++)
    {
        long int n;
        cin >> n;
        cout << differences(n) << endl;
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int logarithm2(long int n)
{
    int k = 0;
    while (n > 0)
    {
        n = n >> 1;
        k++;
    }
    return k;
}
int differences(long int n)
{
    long int a[n];
    for (int x = 0; x < n; x++)
    {
        cin >> a[x];
    }
    long int max_dif = 0;
    for (long int j = 1; j < n; j++)
    {
        for (long int k = 0; k < j; k++)
        {
            max_dif = max(max_dif, a[k] - a[j]);
        }
    }

    return logarithm2(max_dif);
}
int main()
{
    int t;
    cin >> t;
    for (int y = 0; y < t; y++)
    {
        long int n;
        cin >> n;
        cout << differences(n) << endl;
    }
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int t;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        int s;
        cin >> s;
        vector<int> init(0);
        vector<int> even(0);
        vector<int> odd(0);
        for (int j = 0; j < 2 * s; j++)
        {
            int element;
            cin >> element;
            init.push_back(element);
        }
        for (int k = 0; k < 2 * s; k++)
        {
            if (init[k] % 2 == 0)
            {
                even.push_back(k);
            }
            else
            {
                odd.push_back(k);
            }
        }
        int start_index1 = 0, start_index2 = 0;
        if (even.size() % 2 == 0)
        {
            if (even.size() >= odd.size())
            {
                start_index1 = 2;
            }
            else
            {
                start_index2 = 2;
            }
        }
        else
        {
            start_index1 = start_index2 = 1;
        }
        for (int m = start_index1; m < even.size(); m += 2)
        {
            cout << even[m] + 1 << " " << even[m + 1] + 1 << endl;
        }
        for (int q = start_index2; q < odd.size(); q += 2)
        {
            cout << odd[q] + 1 << " " << odd[q + 1] + 1 << endl;
        }
    }
}


#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
void differences(long int n)
{
    long int a[n];
    for (int x = 0; x < n; x++)
    {
        cin >> a[x];
    }
    long int max_dif = 0;
    for (long int j = 1; j < n; j++)
    {
        for (long int k = 0; k < j; k++)
        {
            max_dif = max(max_dif, a[k] - a[j]);
        }
    }
    if (max_dif == 0)
    {
        cout << 0 << endl;
        return;
    }
    cout << (int)log2(max_dif) + 1 << endl;
}
int main()
{
    int t;
    cin >> t;
    for (int y = 0; y < t; y++)
    {
        long int n;
        cin >> n;
        differences(n);
    }
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define repi(it,v) for (auto it=v.begin();it!=v.end();it++)
#define revi(it,v) for (auto it=v.rbegin();it!=v.rend();it++)
//gen
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define all(v) v.begin(),v.end()
#define init(a,i) memeset(a,i,sizeof(a))
//vec
#define vi vector <int>
#define vc vector <char>
#define pb push_back
//set
#define si set <int>
#define in insert

#define endl "\n"
//var
#define L 1000000007
#define mod 100007

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 //type
#define int long long

using namespace std;
signed main()
{
   io;
   int t;
   cin>>t;
   while(t--)
   {
    int n,a,m=INT_MIN,x,mx=0;
    cin>>n;
    rep(i,0,n)
    {
      cin>>a;
      if (a<m)
      {
        x=ceil((float)log(m-a+1)/(float)log(2));
        if ((pow(2,x)-1+a)<m) x++;
        a=pow(2,x)-1+a;
        mx=max(x,mx);
      }
      m=a;

    }
    cout<<mx<<endl;

   }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define repi(it,c) for (auto it=c.begin();it!=c.end();it++)
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define endl "\n"
#define vi vector <int>
#define mod 100007
#define vc vector <char>
#define all(v) v.begin(),v.end()
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long     //type

using namespace std;
signed main()
{
 io;
 int t;
 cin>>t;
 while(t--)
 {
  int n,prev=0,k,f=0,maxx=-1000000009,minn=1000000009;
  cin>>n;
  rep(i,0,n)
  {
    cin>>k;
    maxx=max(maxx,k);
    k<prev?f=1:f;
    prev=k;
    if (f) minn=min(minn,k);
  }
  if (f==0) cout<<0<<endl;
  else
  {
    minn=maxx-minn+1;
    cout<<ceil(log(minn)/log(2))<<endl;
  }

 }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define repi(it,v) for (auto it=v.begin();it!=v.end();it++)
#define revi(it,v) for (auto it=v.rbegin();it!=v.rend();it++)
//gen
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define all(v) v.begin(),v.end()
#define init(a,i) memset(a,i,sizeof(a))
//vec
#define vi vector <int>
#define vc vector <char>
#define pb push_back
//set
#define si set <int>
#define in insert

#define endl "\n"
//var
#define L 1000000007 //10e9
#define mod 100007 //10e5

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 //type
#define int long long

using namespace std;

signed main()
{
  io;
  int t;
  cin>>t;
  while(t--)
  {
    int n,x=0,m=0,min,f=0;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];
   // rep(i,0,n) cout<<a[i]<<" ";cout<<endl;
    int prev=a[0];
    rep(i,1,n)
    {
      if ((a[i]>=prev&&f==0)||(a[i]>=min&&f==1))
      {
        prev=a[i];
        continue;
      }
      else
      {
         f=1;
        while((a[i]<=a[i-1])&&i<n) i++;
        i--;
        min=a[i];
        //cout<<a[i]<<" "<<prev<<" ";
        int k;
        k=prev-a[i]+1;
       // cout<<k<<" ";
        x=ceil(log(k)/log(2));
       // cout<<x<<endl;
        m=max(x,m);
        a[i]+=(pow(2,x)+1);
        prev=a[i];
       // cout<<prev<<" ";
      }
    }
    cout<<m<<endl;
  }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define repi(it,c) for (auto it=c.begin();it!=c.end();it++)
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define endl "\n"
#define vi vector <int>
#define L 1000000007
#define mod 100007
#define init(a,i) memeset(a,i,sizeof(a))
#define vc vector <char>
#define all(v) v.begin(),v.end()
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long     //type

using namespace std;
signed main()
{
 io;
 int t;
 cin>>t;
 while(t--)
 {
  int n,k,f=0,maxx=L*-1,minn=L,pos=-1;
  cin>>n;
  int a[n];
  rep(i,0,n)
  {
    cin>>a[i];
    if (i) a[i]<a[i-1]?f=1:f;
    if (f&&a[i]<=minn)
    {
      minn=a[i];pos=i;
    }
  }
  rep(i,0,pos) maxx=max(a[i],maxx);
  if (f==0) cout<<0<<endl;
  else
  {
    minn=maxx-minn+1;
    cout<<ceil(log(minn)/log(2))<<endl;
  }

 }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define repi(it,c) for (auto it=c.begin();it!=c.end();it++)
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define endl "\n"
#define vi vector <int>
#define mod 100007
#define vc vector <char>
#define all(v) v.begin(),v.end()
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long     //type

using namespace std;
signed main()
{
 io;
 int t;
 cin>>t;
 while(t--)
 {
  int n,prev=0,k,f=0,maxx=0,minn=1000000009;
  cin>>n;
  rep(i,0,n)
  {
    cin>>k;
    maxx=max(maxx,k);
    k<prev?f=1:f;
    prev=k;
    if (f) minn=min(minn,k);
  }
  if (f==0) cout<<0<<endl;
  else
  {
    minn=maxx-minn+1;
    cout<<ceil(log(minn)/log(2))<<endl;
  }

 }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define repi(it,v) for (auto it=v.begin();it!=v.end();it++)
#define revi(it,v) for (auto it=v.rbegin();it!=v.rend();it++)
//gen
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define all(v) v.begin(),v.end()
#define init(a,i) memset(a,i,sizeof(a))
//vec
#define vi vector <int>
#define vc vector <char>
#define pb push_back
//set
#define si set <int>
#define in insert

#define endl "\n"
//var
#define L 1000000007 //10e9
#define mod 100007 //10e5

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 //type
#define int long long

using namespace std;

signed main()
{
  io;
  int t;
  cin>>t;
  while(t--)
  {
    int n,m=0;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];

    rep(i,1,n)
    if (a[i]<a[i-1])
    {
      int x=a[i-1]-a[i]+1;
      int k=ceil((float)log(x)/(float)log(2));
      a[i]+=(pow(2,k)-1);
      if (a[i]<a[i-1])
      {
        a[i]+=pow(2,k);
        k++;
      }
      a[i]=a[i-1];
      m=max(m,k);
    }

    cout<<m<<endl;
   }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define repi(it,v) for (auto it=v.begin();it!=v.end();it++)
#define revi(it,v) for (auto it=v.rbegin();it!=v.rend();it++)
//gen
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define all(v) v.begin(),v.end()
#define init(a,i) memset(a,i,sizeof(a))
//vec
#define vi vector <int>
#define vc vector <char>
#define pb push_back
//set
#define si set <int>
#define in insert

#define endl "\n"
//var
#define L 1000000007 //10e9
#define mod 100007 //10e5

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 //type
#define int long long

using namespace std;

signed main()
{
  io;
  int t;
  cin>>t;
  while(t--)
  {
    int n,x=0,m=0,min,f=0;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];
   // rep(i,0,n) cout<<a[i]<<" ";cout<<endl;
    int prev=a[0];
    rep(i,1,n)
    {
      if ((a[i]>=prev&&f==0)||(a[i]>=min&&f==1))
      {
        prev=a[i];
        continue;
      }
      else
      {
         f=1;
        while(a[i]<=a[i-1]&&i<n) i++;
        i--;
        min=a[i];
        //cout<<a[i]<<" "<<prev<<" ";
        int k;
        k=prev-a[i]+1;
       // cout<<k<<" ";
        x=ceil(log(k)/log(2));
       // cout<<x<<endl;
        m=max(x,m);
        a[i]+=(pow(2,x)+1);
        prev=a[i];
       // cout<<prev<<" ";
      }
    }
    cout<<m<<endl;
  }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define repi(it,c) for (auto it=c.begin();it!=c.end();it++)
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define endl "\n"
#define vi vector <int>
#define mod 100007
#define vc vector <char>
#define all(v) v.begin(),v.end()
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define int long long     //type

using namespace std;
signed main()
{
 io;
 int t;
 cin>>t;
 while(t--)
 {
  int n,prev=-10000000009,k,f=0,maxx=-10000000009,minn=1000000009;
  cin>>n;
  rep(i,0,n)
  {
    cin>>k;
    maxx=max(maxx,k);
    k<prev?f=1:f;
    prev=k;
    if (f) minn=min(minn,k);
  }
  if (f==0) cout<<0<<endl;
  else
  {
    minn=maxx-minn+1;
    cout<<ceil(log(minn)/log(2))<<endl;
  }

 }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define rev(i,a,n) for (int i=a;i>n;i--)
#define repi(it,v) for (auto it=v.begin();it!=v.end();it++)
#define revi(it,v) for (auto it=v.rbegin();it!=v.rend();it++)
//gen
#define pii pair<int,int>
#define fr first
#define sc second
#define mpr make_pair
#define all(v) v.begin(),v.end()
#define init(a,i) memeset(a,i,sizeof(a))
//vec
#define vi vector <int>
#define vc vector <char>
#define pb push_back
//set
#define si set <int>
#define in insert

#define endl "\n"
//var
#define L 1000000007
#define mod 100007

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 //type
#define int long long

using namespace std;
signed main()
{
   io;
   int t;
   cin>>t;
   while(t--)
   {
    int n,m=0;
    cin>>n;
    int a[n];
    rep(i,0,n) cin>>a[i];

    rep(i,1,n)
    if (a[i]<a[i-1])
    {
      int x=a[i-1]-a[i]+1;
      int k=ceil((float)log(x)/(float)log(2));
      a[i]+=(pow(2,k)-1);
      if (a[i]<a[i-1])
      {
        a[i]+=pow(2,k);
        k++;
      }
      m=max(m,k);
    }

    cout<<m<<endl;
   }
  return 0;
}


#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define endl "\n";
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {
	int n, s; cin >> n;
	vector<int> a(n), b;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	b = a;
	for (int i = 0; i < n; ++i) {
		if (i > 0 && a[i] < a[i - 1]) {
			s = 0;
			while(a[i] < a[i - 1]) {
				++s;
				a[i] += pow(2, s - 1);
			}
		}
	}
	int m = -1;
	for (int i = 0; i < n; ++i) {
		// cout << a[i] << " ";
		m = max(m, a[i] - b[i]);
	}
	// cout << endl;
	// _debug(m);
	int p = 0;
	while(m > 0) {
		++p;
		m -= pow(2, p - 1);
	}
	cout << p << endl;
}

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

    int t; cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define endl "\n";
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {
	int n, x = 0, m = 0, y; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> y;
		if (y < x) {
			m = max(m, x - y);
		}
		x = max(x, y);
	}
	cout << ceil(log2(m + 1)) << endl;
}

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

    int t; cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define endl "\n";
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {
	int n, s = 0; cin >> n;
	vector<int> a(n), b;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	b = a;
	for (int i = 0; i < n; ++i) {
		if (i > 0 && a[i] < a[i - 1]) {
			vector<int> check;
			for (int j = i + 1; j < n; ++j) {
				if (a[j] < a[j - 1]) {
					check.push_back(j);
				}
			}
			while(a[i] < a[i - 1]) {
				++s;
				a[i] += pow(2, s - 1);
				for (auto &u : check) {
					a[u] += pow(2, s - 1);
				}
			}
		}
	}
	int m = -1;
	for (int i = 0; i < n; ++i) {
		// cout << a[i] << " ";
		m = max(m, a[i] - b[i]);
	}
	// cout << endl;
	int p = 0;
	// _debug(m);
	while(m > 0) {
		++p;
		m -= pow(2, p);
	}
	cout << p << endl;
	// cout << min(s, p) << endl;
	// cout << s << endl;
}

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

    int t; cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define endl "\n";
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

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

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

    int t; cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define endl "\n";
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {
	int n, s = 0; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		if (i > 0 && a[i] < a[i - 1]) {
			vector<int> check;
			for (int j = i + 1; j < n; ++j) {
				if (a[j] < a[j - 1]) {
					check.push_back(j);
				}
			}
			while(a[i] < a[i - 1]) {
				++s;
				a[i] += pow(2, s - 1);
				for (auto &u : check) {
					a[u] += pow(2, s - 1);
				}
			}
		}
	}
	cout << s << endl;
}

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

    int t; cin >> t;
    while(t--)
        solve();
}


#include <bits/stdc++.h>
#define INF 1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define arr array
#define endl "\n";
#define _min(a) *min_element(a.begin(), a.end());
#define _max(a) *max_element(a.begin(), a.end());
#define _sort(x) sort(x.begin(), x.end())
#define _rsort(x) sort(x.rbegin(), x.rend())
#define _reverse(x) reverse(x.begin(), x.end())
#define _debug(x) cout << #x << " = " << x << endl;
#define debug(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define _lower_bound(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()
#define _upper_bound(a, x) upper_bound(a.begin(), a.end(), x) - a.begin()
typedef long long ll;
using namespace std;

void solve() {
	int n, s; cin >> n;
	vector<int> a(n), b;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	b = a;
	for (int i = 0; i < n; ++i) {
		if (i > 0 && a[i] < a[i - 1]) {
			s = 0;
			while(a[i] < a[i - 1]) {
				++s;
				a[i] += pow(2, s);
			}
		}
	}
	int m = -1;
	for (int i = 0; i < n; ++i) {
		// cout << a[i] << " ";
		m = max(m, a[i] - b[i]);
	}
	// cout << endl;
	// _debug(m);
	int p = 0;
	while(m > 0) {
		++p;
		m -= pow(2, p - 1);
	}
	cout << p << endl;
}

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

    int t; cin >> t;
    while(t--)
        solve();
}


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

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			int need = ceil(log(nums[i - 1] - nums[i]) / log(2));
			t = max(t, need + 1);
			nums[i] += 1 << need;
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			int need = ceil(log(nums[i - 1] - nums[i] + 1) / log(2));
			t = max(t, need);
			nums[i] += 1 << need - 1;
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<long long> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			string need = bitset<32>(nums[i - 1] - nums[i]).to_string();
			int highest;
			for (int i = 0; i < 32; i++) {
				if (need[i] == '1') {
					highest = 32 - i;
					break;
				}
			}
			t = max(t, highest);
			nums[i] = nums[i - 1];
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<long long> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			string need = bitset<30>(nums[i - 1] - nums[i]).to_string();
			int highest;
			for (int i = 0; i < 30; i++) {
				if (need[i] == '1') {
					highest = 30 - i;
					break;
				}
			}
			t = max(t, highest);
			nums[i] = nums[i - 1];
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			float ans = log(nums[i - 1] - nums[i]) / log(2);
			// cout << ans << "\n";
			int need = floor(ans);
			t = max(t, need + 1);
			nums[i] += 1 << need;
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<long long> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			int need = ceil(log(nums[i - 1] - nums[i] + 1) / log(2));
			t = max(t, need);
			nums[i] += (1 << need) - 1;
		}
	}
	// for (int i = 0; i < n; i++) {
	// 	cout << nums[i] << " ";
	// }
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	while (1) {
		bool good = 1;
		for (int i = 1; i < n; i++) {
			if (nums[i] < nums[i - 1]) {
				good = 0;
				nums[i] += 1 << t;
			}
		}
		if (good) break;
		t++;
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<long long> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			int need = ceil(log(nums[i - 1] - nums[i] + 1) / log(2));
			t = max(t, need);
			nums[i] += 1 << need - 1;
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			float ans = log(nums[i - 1] - nums[i] + 1) / log(2);
			// cout << "DEBUG: " << ans << "\n";
			int need = ceil(ans);
			t = max(t, need);
			nums[i] += 1 << need - 1;
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


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

void solve() {
	int n;
	cin >> n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	int t = 0;
	for (int i = 1; i < n; i++) {
		if (nums[i] < nums[i - 1]) {
			double ans = log(nums[i - 1] - nums[i]) / log(2);
			int need = ceil(ans);
			t = max(t, need + 1);
			nums[i] += 1 << need;
		}
	}
	cout << t << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		solve();
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
    int t;
    cin >> t;

    for(int i=0;i<t;i++){
        int n, c = 0;
        cin >> n;

        long long arr[n];
        for(int j=0;j<n;j++){
            cin >> arr[j];
        }
        int k, x = 1, count = 0;
        for(int j=1;j<n;j++){
            int diff = arr[j] - arr[j-1];
            if(diff<0){
                while(abs(diff)>pow(2, x-1)){
                    count++;
                    diff += pow(2, x-1);
                    x++;
                }
                x++;
                count++;
            }
        }
        cout << count << endl;
    }
}


#include<bits/stdc++.h>

using namespace std;

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

   int t;
   t = 1;
   cin >> t;

   long long sum[31];

    for(int i=0;i<31;i++){
        sum[i] = pow(2,i);
    }

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

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

        int c = 0;

        vector<int> v;
        long long ans = 0;
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]){
                long long diff = arr[i-1] - arr[i];
                if(c==1){
                    if(v[v.size()-1]==31){
                        ans++;
                    }else{
                        long long p = 0;
                        for(int j=v[v.size()-1];j<31;j++){
                            p += sum[j];
                            if((diff/p)==0 || (diff==p)){
                                ans+=((j+1) - v[v.size()-1]);
                                break;
                            }
                        }
                    }
                }else{
                    long long p = 0;
                    for(int j=0;i<31;j++){
                        p+=sum[j];
                        if((diff/p)==0 || (diff==p)){
                            v.push_back(j+1);
                            break;
                        }
                    }
                }
                c = 1;
            }else{
                c = 0;
            }
        }
        if(v.size()>0)
            cout << ans + *max_element(v.begin(), v.end())  << endl;
        else
            cout << ans << endl;
   }
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;

void solve(){
  int n;
  cin >> n;

  ll a[n];
  fo(i, n){
    cin >> a[i];
  }

  ll diff = 0;
		ll mx = a[0];
		for(int i = 0; i < n; i++)
		{
			diff = max(diff,mx-a[i]);
			mx = max(mx,a[i]);
		}

		int steps = 1;
		while(diff > 0)
		{
			diff-=pow(2,steps-1);
			steps++;
		}

    cout << steps - 1 <<endl;

}

int main(){
	fast_io;

  int t = 1;
  cin >> t;

  while(t--){
    solve();
  }
}


#include<bits/stdc++.h>

using namespace std;

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

   int t;
   t = 1;
   cin >> t;

   long long sum[30];

    sum[0] = 1;

    for(int i=1;i<30;i++){
        sum[i] = pow(2,i) + sum[i-1];
    }

   while(t--){
        int n;
        cin >> n;
        long long ans = 0;

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

        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]){
                long long diff = arr[i-1] - arr[i];
                for(int j=0;j<30;j++){
                    if((diff/sum[j])==0 || (diff==sum[j])){
                        ans+=(j+1);
                        break;
                    }
                }
            }
        }
        cout << ans << endl;
   }
}


#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;

void solve(){
  int n;
  cin >> n;

  ll arr[n];
  fo(i, n){
    cin >> arr[i];
  }

  ll diff[n];
  diff[0] = 0;
  Fo(i, 1, n){
    diff[i] = arr[i] - arr[i-1];
  }

  int t = 1;

  fo(i, n){
    if(diff[i]<0){
      while(abs(diff[i])>pow(2, t-1)){
        t++;
      }
      t++;
    }
  }
  cout << t-1 << endl;

}

int main(){
	fast_io;

  int t = 1;
  cin >> t;

  while(t--){
    solve();
  }
}


#include<bits/stdc++.h>

using namespace std;

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

   int t;
   t = 1;
   cin >> t;

   long long sum[31];

    sum[0] = 1;

    for(int i=1;i<31;i++){
        sum[i] = pow(2,i) + sum[i-1];
    }

   while(t--){
        int n;
        cin >> n;
        long long ans = 0;

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

        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]){
                long long diff = arr[i-1] - arr[i];
                for(int j=0;j<30;j++){
                    if((diff/sum[j])==0 || (diff==sum[j])){
                        ans+=(j+1);
                        break;
                    }
                }
            }
        }
        cout << ans << endl;
   }
}


#include<bits/stdc++.h>

using namespace std;

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

   int t;
   t = 1;
   cin >> t;

   long long sum[31];

    sum[0] = 1;

    for(int i=1;i<31;i++){
        sum[i] = pow(2,i) + sum[i-1];
    }

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

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

        int c = 0;

        vector<int> v;
        long long ans = 0;
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]){
                long long diff = arr[i-1] - arr[i];
                if(c==1){
                    if(v[v.size()-1]==30){
                        ans++;
                    }else{
                        for(int j=v[v.size()-1];j<31;j++){
                            if((diff/sum[j])==0 || (diff==sum[j])){
                                ans+=((j+1) - v[v.size()-1]);
                                break;
                            }
                        }
                    }
                }else{
                    for(int j=0;i<31;j++){
                        if((diff/sum[j])==0 || (diff==sum[j])){
                            ans += (j+1);
                            v.push_back(j);
                            break;
                        }
                    }
                }
                c = 1;
            }else{
                c = 0;
            }
        }
        cout << ans << endl;
   }
}


#include<bits/stdc++.h>

using namespace std;

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

   int t;
   t = 1;
   cin >> t;

   long long sum[31];

    for(int i=0;i<31;i++){
        sum[i] = pow(2,i);
    }

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

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

        int c = 0;

        vector<int> v;
        long long ans = 0;
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]){
                long long diff = arr[i-1] - arr[i];
                if(c==1){
                    if(v[v.size()-1]==31){
                        ans++;
                    }else{
                        long long p = 0;
                        for(int j=v[v.size()-1];j<31;j++){
                            p += sum[j];
                            if((diff/p)==0 || (diff==p)){
                                ans+=((j+1) - v[v.size()-1]);
                                break;
                            }
                        }
                    }
                }else{
                    long long p = 0;
                    for(int j=0;i<31;j++){
                        p+=sum[j];
                        if((diff/p)==0 || (diff==p)){
                            ans += (j+1);
                            v.push_back(j+1);
                            break;
                        }
                    }
                }
                c = 1;
            }else{
                c = 0;
            }
        }
        cout << ans << endl;
   }
}


#include <iostream>
#include<algorithm>

using namespace std;

int main()
{
    int t,n,i,j,seconds = 1;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>n;
        long long int arr[100005];
        for(j=0;j<n;j++)
        {
            cin>>arr[j];
        }
        for(j=0;j<n-1&&arr[j]<arr[j+1];j++)
        {
            int k;
            k++;
        }
        if(j == n-1)
        {
            cout<<0<<endl;
        }
        else if(arr[j] > arr[j+1])
        {
            while(arr[j] > arr[j+1])
            {
                sort(arr+j+1,arr+n);
                arr[j+1] += (2^(seconds-1));
                seconds++;
            }
        }
        cout<<seconds<<endl;
    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int i,n,j,recieve = 0,ans = 0;
		cin>>n;
		vector<long long> v(n);
		for (i = 0; i < n; ++i)
		{
			cin>>v[i];
		}
		for(i=0;i<n-1;i++)
		{
			if(v[i+1]<v[i])
			{
				recieve = 1;
				long long diff = v[i]-v[i+1] + 1;
				long long val = ceil(log2(diff));
				ans = max(ans,val);
			}
		}
		if(recieve == 0)
		{
			cout<<0<<endl;
		}
		else
		{
			cout<<ans<<endl;
		}
	}

}


#include <iostream>
#include<algorithm>

using namespace std;

int main()
{
    int t,n,i,j,seconds = 1;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>n;
        seconds = 1;
        long long int arr[100005];
        for(j=0;j<n;j++)
        {
            cin>>arr[j];
        }
        for(j=0;j<n-1&&arr[j]<arr[j+1];j++)
        {
            int k;
            k++;
        }
        if(j == n-1)
        {
            cout<<0<<endl;
        }
        else if(arr[j] > arr[j+1])
        {
            while(arr[j] > arr[j+1])
            {
                sort(arr+j+1,arr+n);
                arr[j+1] += (2^(seconds-1));
                seconds++;
            }
            cout<<seconds<<endl;
        }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int i,n,j,recieve = 0;
		long long ans =0;
		cin>>n;
		vector<long long> v(n);
		for (i = 0; i < n; ++i)
		{
			cin>>v[i];
		}
		for(i=0;i<n-1;i++)
		{
			if(v[i+1]<v[i])
			{
				recieve = 1;
				long long diff = v[i]-v[i+1] + 1;
				long long val = ceil(log2(diff));
				ans = max(ans,val);
			}
		}
		if(recieve == 0)
		{
			cout<<0<<endl;
		}
		else
		{
			cout<<ans<<endl;
		}
	}

}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int i,n,j,recieve = 0;
		long long ans = INT_MIN;
		cin>>n;
		vector<long long> v(n);
		for (i = 0; i < n; ++i)
		{
			cin>>v[i];
		}
		for(i=0;i<n-1;i++)
		{
			if(v[i+1]<v[i])
			{
				recieve = 1;
				long long diff = v[i]-v[i+1];
				diff++;
				long long val = ceil(log2(diff));
				ans = max(ans,val);
				v[i+1] = v[i];
			}
		}
		if(recieve == 0)
		{
			cout<<0<<endl;
		}
		else
		{
			cout<<ans<<endl;
		}
	}

}


#include <iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
    int t,n,i,j,k,seconds = 1,recieve = 0;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>n;
        seconds = 1;
        recieve = 0;
        long long int arr[100005];
        for(j=0;j<n;j++)
        {
            cin>>arr[j];
        }
        for(j=0;j<n-1;j++)
        {
            if(arr[j] > arr[j+1])
            {   recieve = 1;
                while(arr[j] > arr[j+1])
                {
                    for(k= j+1;k<n;k++)
                    {
                        arr[k] += (pow(2,(seconds-1)));

                    }

                    seconds++;
                }

            }
        }
        if(recieve == 0)
        {
            cout<<0<<endl;
        }
        else if(recieve == 1)
        {
            cout<<seconds-1<<endl;
        }

    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    int top = -2e9;
    int gap = 0;
    while (n--) {
        int a;
        cin >> a;
        if (a > top) {
            top = a;
        } else {
            gap = max(gap, top - a);
        }
    }
    int res = 0;
    while (gap > 0) {
        gap >>= 1;
        res++;
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    int top = -2e9;
    int gap = 0;
    while (n--) {
        int a;
        cin >> a;
        if (a > top) {
            top = a;
        } else {
            gap = max(gap, top - a);
        }
    }
    if (gap == 0) {
        cout << 0;
    } else {
        cout << (log(gap) / log(2)) + 1;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    int top = -2e9;
    int gap = 0;
    while (n--) {
        int a;
        cin >> a;
        if (a > top) {
            top = a;
        } else {
            gap = max(gap, top - a);
        }
    }
    cout << max(0ll, ll(log(gap) / log(2)) + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    int top = -2e9;
    int gap = 0;
    while (n--) {
        int a;
        cin >> a;
        if (a > top) {
            top = a;
        } else {
            gap = max(gap, top - a);
        }
    }
    if (gap == 0) {
        cout << 0;
    } else {
        cout << int(log(gap) / log(2)) + 1;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    int top = -2e9;
    int gap = 0;
    while (n--) {
        int a;
        cin >> a;
        if (a > top) {
            top = a;
        } else {
            gap = max(gap, top - a);
        }
    }
    if (gap == 0) {
        cout << 0;
    } else {
        cout << ceil(log(gap) / log(2)) + 1;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;
    int top = -2e9;
    int gap = 0;
    while (n--) {
        int a;
        cin >> a;
        if (a > top) {
            top = a;
        } else {
            gap = max(gap, top - a);
        }
    }
    cout << max(0, int(log(gap) / log(2) + 1));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1100, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll p, n, x, power[100];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	cin >> p;
	power[0] = 1;
	ll j = 1, k = 1;
	while (1) {
		k *= 2;
		power[j] = power[j - 1] + k;
		if (power[j] > 3e9)
			break;
		++j;
	}
	ll y = j;
	while (p--) {
		cin >> n;
		vector<ll> t;
		rep(i, 0, n) {
			cin >> x;
			t.push_back(x);
		}
		ll rs = 0;
		rep(i, 1, n) {
			if (t[i] >= t[i - 1])
				continue;
			ll l = 0, r = y;
			while (r - l > 1) {
				ll m = (r + l) / 2;
				if (t[i] + power[m] >= t[i - 1])
					r = m;
				else
					l = m;
			}
			rs = max(rs, r + 1);
			t[i] += power[r];
		}
		cout << rs << '\n';
	}
}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1100, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll p, n, x, power[100];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	cin >> p;
	power[0] = 1;
	ll j = 1, k = 1;
	while (1) {
		k *= 2;
		power[j] = power[j - 1] + k;
		if (power[j] > 3e9)
			break;
		++j;
	}
	ll y = j;
	while (p--) {
		cin >> n;
		vector<ll> t;
		rep(i, 0, n) {
			cin >> x;
			t.push_back(x);
		}
		ll rs = 0;
		rep(i, 1, n) {
			if (t[i] >= t[i - 1])
				continue;
			ll l = 0, r = y;
			while (r - l > 1) {
				ll m = (r + l) / 2;
				if (t[i] + power[m] >= t[i - 1])
					r = m;
				else
					l = m;
			}
			if (t[i] + power[l] >= t[i - 1]) {
				t[i] += power[l];
				rs = max(rs, r + 1);
			}
			else {
				rs = max(rs, r + 1);
				t[i] += power[r];
			}
		}
		cout << rs << '\n';
	}
}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1e6, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll n, t;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	cin >> t;
	while (t--) {
		cin >> n;
		ll rs = 0;
		vector<ll> t;
		t.resize(n);
		rep(i, 0, n) {
			cin >> t[i];
		}
		rep(i, 1, n) {
			if (t[i] > t[i - 1])
				continue;
			ll deg = -1;
			while (t[i] < t[i - 1]) {
				++deg;
				t[i] += (1LL << deg);
			}
			t[i] = t[i - 1];
			rs = max(rs, deg);
		}
		if (rs == 0)
			cout << rs << '\n';
		else
			cout << rs + 1 << '\n';
	}

}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1100, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll p, n, x, power[100];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	cin >> p;
	power[0] = 1;
	int j = 1, k = 1;
	while (1) {
		k *= 2;
		power[j] = power[j - 1] + k;
		if (power[j] > 2e9)
			break;
		++j;
	}
	int y = j;
	while (p--) {
		cin >> n;
		vector<ll> t;
		rep(i, 0, n) {
			cin >> x;
			t.push_back(x);
		}
		int rs = 0;
		rep(i, 1, n) {
			if (t[i] >= t[i - 1])
				continue;
			int l = 0, r = y;
			while (r - l > 1) {
				int m = (r + l) / 2;
				if (t[i] + power[m] >= t[i - 1])
					r = m;
				else
					l = m;
			}
			rs = max(rs, r + 1);
		}
		cout << rs << '\n';
	}
}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1e6, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll n, t;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	cin >> t;
	while (t--) {
		cin >> n;
		ll rs = -1;
		vector<ll> t;
		t.resize(n);
		rep(i, 0, n) {
			cin >> t[i];
		}
		rep(i, 1, n) {
			if (t[i] >= t[i - 1])
				continue;
			ll deg = -1;
			while (t[i] < t[i - 1]) {
				++deg;
				t[i] += (1LL << deg);
			}
			t[i] = t[i - 1];
			rs = max(rs, deg);
		}
		cout << rs + 1 << '\n';
	}

}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1100, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll p, n, x, power[100];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	cin >> p;
	power[0] = 1;
	ll j = 1, k = 1;
	while (1) {
		k *= 2;
		power[j] = power[j - 1] + k;
		if (power[j] > 3e9)
			break;
		++j;
	}
	ll y = j;
	while (p--) {
		cin >> n;
		vector<ll> t;
		rep(i, 0, n) {
			cin >> x;
			t.push_back(x);
		}
		ll rs = 0;
		rep(i, 1, n) {
			if (t[i] >= t[i - 1])
				continue;
			ll l = 0, r = y;
			while (r - l > 1) {
				ll m = (r + l) / 2;
				if (t[i] + power[m] >= t[i - 1])
					r = m;
				else
					l = m;
			}
			if (t[i] + power[l] >= t[i - 1]) {
				t[i] += power[l];
				rs = max(rs, l + 1);
			}
			else {
				rs = max(rs, r + 1);
				t[i] += power[r];
			}
		}
		cout << rs << '\n';
	}
}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1e6, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll n, t;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

	cin >> t;
	while (t--) {
		cin >> n;
		ll rs = 0;
		vector<ll> t;
		t.resize(n);
		rep(i, 0, n) {
			cin >> t[i];
		}
		rep(i, 1, n) {
			if (t[i] > t[i - 1])
				continue;
			ll deg = -1;
			while (t[i] < t[i - 1]) {
				++deg;
				t[i] += (1 << deg);
			}
			t[i] = t[i - 1];
			rs = max(rs, deg);
		}
		if (rs == 0)
			cout << rs << '\n';
		else
			cout << rs + 1 << '\n';
	}

}


#pragma GCC target("avx2")
#pragma comment(linker, "/STACK:10000000000")
#define _CRT_SECURE_NO_WARNINGS
#include<algorithm>
#include<iostream>
#include<cmath>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>

#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r - 1; i >= l; --i)
typedef long long ll;
typedef long double ld;

using namespace std;

const long long N = 1e6, MOD = 1e9 + 7, INF = 1e9, miniINF = 1e5, M = 2e5;
const long long bigINF = 1e18;
const ld EPS = 1e-9, pi = 3.141592653589793238462, rad = 57.2957795;

ll n, t, val[N], deg[N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
	ll q = 2, ind = 2;
	deg[1] = 1;
	while (q <= 2 * 1e9) {
		deg[ind] = q + deg[ind - 1];
		q *= 2;
		++ind;
	}
	deg[ind] = q + deg[ind - 1];

	cin >> t;
	while (t--) {
		cin >> n;
		ll rs = 0;
		vector<ll> t;
		t.resize(n);
		rep(i, 0, n) {
			cin >> t[i];
		}
		reverse(t.begin(), t.end());
		ll mx_n = t.back();
		per(i, n, 0) {
			if (t[i] >= mx_n) {
				mx_n = t[i];
				continue;
			}
			ll l = 0, r = ind + 1;
			while (r - l > 1) {
				ll m = (r + l) / 2;
				if (deg[m] + t[i] >= mx_n) {
					r = m;
				}
				else {
					l = m;
				}
			}
			if (deg[l] + t[i] >= mx_n) {
				rs = max(rs, l);
				t[i] += deg[l];
			}
			else {
				rs = max(rs, r);
				t[i] += deg[r];
			}
			mx_n = t[i];
		}
		cout << rs << '\n';
	}

}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  int ans=0;
  for(i=1;i<n;i++)
  {
    int d= a[i]-a[i-1];
    if(d<0)
    {
      d=-d;
      x=1;
      int k=1;
      while(2*x<=d)
      {
        x*=2;
        k++;
      }
      ans= max(ans, k);
      a[i]= a[i-1];
    }
  }
  cout<<ans<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n],b[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2*1e9)break;
  }
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(i-1>=0)
    b[i]= max(b[i-1], a[i]);
    else
      b[i]= a[i];
    int d= b[i]-a[i];
    int ind= lower_bound(all(v),d)-v.begin();
    ans= max(ans, ind);
  }
  cout<<ans<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2*1e9)break;
  }
  for(i=1;i<v.size();i++)
    v[i]+=v[i-1];
  int fl=-1;
  for(i=0;i+1<n;i++)
  {
    if(a[i]>a[i+1])
    {
      fl=i;
      break;
    }
  }
  if(fl==-1){
    cout<<"0\n";
    return;
  }
  int diff=0;
  for(i=fl;i<n;i++)
  {
    diff= max(diff, abs(a[i]-a[fl]));
  }
  int ind= lower_bound(all(v), diff)-v.begin();
  if(ind==v.size())ind--;
  cout<<ind<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n],b[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2*1e9)break;
  }
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(i-1>=0)
    b[i]= max(b[i-1], a[i]);
    else
      b[i]= a[i];
    int d= b[i]-a[i];
    int ind= lower_bound(all(v),d)-v.begin();
    if(ind==32)ind--;
    ans= max(ans, ind);
  }
  cout<<ans<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2000000000000000000)break;
  }
  int fl=-1;
  for(i=0;i+1<n;i++)
  {
    if(a[i]>a[i+1])
    {
      fl=i;
      break;
    }
  }
  if(fl==-1){
    cout<<"0\n";
    return;
  }
  int diff=-2000000000000000000;
  for(i=fl;i<n;i++)
  {
    diff= max(diff, abs(a[i]-a[fl]));
  }
  int ind= lower_bound(all(v), diff)-v.begin();
  cout<<ind<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n],b[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2*1e9)break;
  }
  int ans=0;
  for(i=0;i<n;i++)
  {
    if(i-1>=0)
    b[i]= max(b[i-1], a[i]);
    else
      b[i]= a[i];
    int d= b[i]-a[i];
    ans= max(ans, lower_bound(all(v),d)-v.begin());
  }
  cout<<ans<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2*1e9)break;
  }
  int fl=-1;
  for(i=0;i+1<n;i++)
  {
    if(a[i]>a[i+1])
    {
      fl=i;
      break;
    }
  }
  if(fl==-1){
    cout<<"0\n";
    return;
  }
  int diff=0;
  for(i=fl;i<n;i++)
  {
    diff= max(diff, abs(a[i]-a[fl]));
  }
  int ind= lower_bound(all(v), diff)-v.begin();
  if(ind==v.size())ind--;
  if(v[ind]>diff)ind--;
  cout<<ind<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2000000000000000000)break;
  }
  int fl=-1;
  for(i=0;i+1<n;i++)
  {
    if(a[i]>a[i+1])
    {
      fl=i;
      break;
    }
  }
  if(fl==-1){
    cout<<"0\n";
    return;
  }
  int diff=0;
  for(i=fl;i<n;i++)
  {
    diff= max(diff, abs(a[i]-a[fl]));
  }
  int ind= lower_bound(all(v), diff)-v.begin();
  cout<<ind<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>2*1e9)break;
  }
  int fl=-1;
  for(i=0;i+1<n;i++)
  {
    if(a[i]>a[i+1])
    {
      fl=i;
      break;
    }
  }
  if(fl==-1){
    cout<<"0\n";
    return;
  }
  int diff=0;
  for(i=fl;i<n;i++)
  {
    diff= max(diff, abs(a[i]-a[fl]));
  }
  int ind= lower_bound(all(v), diff)-v.begin();
  if(ind==v.size())ind--;
  cout<<ind<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int x=1;
  vector<int>v;
  v.pb(0);
  for(i=1;;i++)
  {
    v.pb(x);
    x=x*2;
    if(x>1e9)break;
  }
  int fl=-1;
  for(i=0;i+1<n;i++)
  {
    if(a[i]>a[i+1])
    {
      fl=i;
      break;
    }
  }
  if(fl==-1){
    cout<<"0\n";
    return;
  }
  int diff=-1e18;
  for(i=fl;i<n;i++)
  {
    diff= max(diff, abs(a[i]-a[fl]));
  }
  int ind= lower_bound(all(v), diff)-v.begin();
  cout<<ind<<"\n";
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  //t=1;
  cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <set>
#include <deque>
#include <map>
using namespace std;

#define rep(i,si,n) for(int i=si;i<n;i++)
#define F first
#define S second
#define mp make_pair
#define en '\n'
#define ll long long int
#define pb push_back
#define MAXN 1000000

typedef pair<ll, ll> pr;
int mod = 1e9 + 7;

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

}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = ans * a;
		a *= a;
		b = b >> 1;
	}
	return ans;
}

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

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];

		int x = 1;
		int i = 1;
		int ctr = 0;
		int sum = 0;
		while (i < n) {
			int val = arr[i] + sum;
			//cout << arr[i - 1] << en;
			while (val < arr[i - 1]) {
				val += x;
				sum += x;
				ctr++;
				x *= 2;
				//	cout << i << en;
			}
			arr[i] += sum;
			//cout << sum << " " << i << en;
			//sum += val - arr[i];
			//vec.pb(val - arr[i]);
			i++;
		}

		cout << ctr << en;
	}
}


#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <set>
#include <deque>
#include <map>
using namespace std;

#define rep(i,si,n) for(int i=si;i<n;i++)
#define F first
#define S second
#define mp make_pair
#define en '\n'
#define ll long long int
#define pb push_back
#define MAXN 1000000

typedef pair<ll, ll> pr;
int mod = 1e9 + 7;

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

}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = ans * a;
		a *= a;
		b = b >> 1;
	}
	return ans;
}

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

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];
		set<int >set;
		int max = arr[1];
		rep(i, 1, n) {
			if (arr[i] > max) {
				max = arr[i];
				set.insert(i);
			}
		}

		int x = 1;
		int i = 1;
		int ctr = 0;
		int sum = 0;
		while (i < n) {
			if (set.count(i) != 0) {
				i++;
				continue;
			}
			int val = arr[i] + sum;
			//cout << arr[i - 1] << en;
			while (val < arr[i - 1]) {
				val += x;
				sum += x;
				ctr++;
				x *= 2;
				//	cout << i << en;
			}
			arr[i] += sum;
			//cout << sum << " " << i << en;
			//sum += val - arr[i];
			//vec.pb(val - arr[i]);
			i++;
		}

		cout << ctr << en;
	}
}


#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <cstring>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <bitset>
#include <numeric>
#include <set>
#include <deque>
#include <map>
using namespace std;

#define rep(i,si,n) for(int i=si;i<n;i++)
#define F first
#define S second
#define mp make_pair
#define en '\n'
#define ll long long int
#define pb push_back
#define MAXN 1000000

typedef pair<ll, ll> pr;
int mod = 1e9 + 7;

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

}

ll power(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b & 1)
			ans = ans * a;
		a *= a;
		b = b >> 1;
	}
	return ans;
}

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

	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		int arr[n];
		rep(i, 0, n)cin >> arr[i];

		int mx = INT_MIN;
		int diff = 0;
		rep(i, 0, n) {
			mx = max(mx, arr[i]);
			diff = max(diff, mx - arr[i]);
		}
		int ans = 0;
		if (diff == 0)
			ans = 0;
		else {
			while (diff > 0) {
				diff /= 2;
				ans++;
			}
		}
		cout << ans << en;
	}
}