You are given an array $$$A$$$ of $$$N$$$ positive integers and you are allowed to construct new array $$$B$$$ in the following manner: Traverse $$$A$$$ from left to right and for each $$$i$$$ you can put $$$A_i$$$ either to the left or right of $$$B$$$ ($$$B$$$ is initially empty). You need to maximize the sum of all prefix XORs of $$$B$$$, that is, maximize $$$(B_1) + (B_1 xor B_2) + (B_1 xor B_2 xor B_3)...$$$
This question was asked in an online assessment for which one of my friends appeared. Both of us weren't able to solve it. Can someone please help me out?