Whats wrong in code shows wrong answer

using namespace std;

int main(){
ll t;// ll long long
cin>>t;

while(t-->0){
    ll n;
    cin>>n;
    ll minStep=0;
    ll msbPos=-1;// since start from 2^0
    ll temp=n;
    while (temp>0)
    {
        msbPos++;
        temp>>=1;
    }
    minStep=(n-(1<<msbPos))+1;//-  has higher precedence than <<
cout<<minStep<<endl;
}

return 0;

}

In this problem you just have to count the number of set bits in a number. That itself will be the answer. Please recheck your logic.