check again.
Updated Now. 
Why the solution of other programmers are still hidden?
The practice link is not working
The solution you provided is indeed incorrect. It’s showing wrong answer in some of the test cases
I understand your frustuation. But Atleast don’t call someone dumb!! have some decency brother
How did you submitted it Because I am not able to open practice link
Check for this input:
4
1 2 5 8
Correct ans = 15
- 1 and 2 will go --> 2
- 1 will return --> 3
- 5 and 8 will go --> 11
- 2 will return --> 13
- 1 and 2 will go --> 15
Check it properly
My code is outputting only 15
Check for this one:
5
23 22 2 18 6
Correct ans = 63
Your answer = 75
I hope this will work now.Also above logic is incorrect if row is not sorted before calling recurse I think.
The reason for this is that while calculating RIGHTMASK from LEFTMASK we assume that all elements not in LEFT are at right but for cases much smaller than (1<<n) we have not included that element and if not sorted this may use an element which was not at all considered
Your solution is working fine but i don’t know why it’s getting more time which will definitely time out in 2 sec.
It’s python
Time limit will be 10s I think 
Anyways still if it’s TLE you can try C++ with Fast IO
I didn’t get any reply from the question setter till now. This is the reason why i call certain people dumb.
@hruday968, calling another person dumb for not replying makes no sense. It was harsh on your part. I did not visit codechef for some days now and also the question appear on the first page, so that I could come to know about it. About your anger, I saw your code and see the editorial carefully, it uses bitmasks and bitwise operations, which are O(1) everywhere. Refer to my code for it.
Regarding your code, I saw it too and ran it locally and on online judge regarding the last test cases, it is very slow due to the O(n) operations which you do every time, instead of the O(1) bitwise operations. Also, every call of the recursive call you make has a O(n logn) factor due to the power function call you make (along with the costly mod operations, which is not needed anyway). This just makes the case worse, I tried atleast that part and it passes the second las test cases now. Here is your optimsed code : UJbC9p - Online C++0x Compiler & Debugging Tool - Ideone.com
Last few things, if you don’t know them. First of all increasing memory sizes just makes things worse, especially in recursive written codes as there are almost all cache misses. A code written with all bitwise operations only works amost 3-4 times faster, allowing even 2-3*{10}^{8} operations to work even in 1 sec.