XOR Profit problem

i am not able to understand how to code this problem

@Sfo_2302 n is 1000 only try to think of bruteforce

How to change MSB? I tried to apply bruteforce but it gave me wrong answer

@Sfo_2302 like this