XOR Small, https://www.codechef.com/problems/XORSMALL?tab=statement

#include <bits/stdc++.h>
#define lp(n) for(int i=0; i<n; i++)
#define ll long long
#define endl '\n'
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define FAST_IO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;

int main() {
    FAST_IO;
    int t;
    cin >>t;
    
    while(t--){
        int n;
        cin >> n;
        ll a[n];
        bool odd = true;
        lp(n) {
            cin >> a[i];
            if(a[i]%2==0) odd=false;
        }
        
        ll l=INT_MIN, r=INT_MAX;
        ll ans = odd?1:0;
        for(int i=0; i<n; i++){
            ll p = 1 << (32 - __builtin_clz(a[i]-1));
            if(p==a[i]){
                l = max(l, p);
                r = min(r, p*2 - 1);
            } else{
                l = max(l, p/2);
                r = min(r, p-1);
            }
        }
        ans += (l <= r ? r-l+1 : 0);
        cout << ans  << endl;
    }
}

it can be seen with some example that for any number
Let say 5, it will result in lower values then 5 when xor with number in the range of 4 to 8-1, that is 2^n to 2^n-1,
For 8 it is 8 to 16-1,
In the code I am finding the power of 2 which is greater than or equal to the number a[i] then then updating the l and r, l and r here are the lower and upper limit of values in to which if we xor any number in the series we will get smaller number.
Also for odd number if xor them with 1 they will result in smaller number, so if all the numbers are odd then just add 1 to the answer.
So if anyone can help and tell me where i went wrong?

1
3
1 1 1
Your code is failing for this test case, the answer is ‘1’

hint: think from the most significant bit to the least one
( in every bitwise operator problem, also think in terms of ‘BITS’