Limits 1s, 512 MB

You are given an array AAA of NNN positive integers A1,A2,………..,AN−1,ANA_1, A_2, ………..,A_{N-1}, A_NA1,A2,………..,AN−1,AN which are some powers of 222. You have to do the following operations on the array-

This is a companion discussion topic for the original entry at https://toph.co/p/xorand-coupling