One Liner Python3.
Approach\nfind leftmost 1 in rightmost sequence of 1s and flip it.\ny=x^(x+1) gives mask including rightmost 0.\nflip second most significant bit of y in x.\n# 
# Approach\nfind leftmost 1 in rightmost sequence of 1s and flip it.\n`y=x^(x+1)` gives mask including rightmost 0.\nflip second most significant bit of y in x.\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n# Code\n```python3 []\nclass Solution:\n    def minBitwiseArray(self, nums: List[int]) -> List[int]:\n        return [-1 if x==2 else x^ ( (x^(x+1)) >>1 ) ^ ( (x^(x+1)) >>2 )  for x in nums]\n```
['Python3']