3314. Construct the Minimum Bitwise Array I

You are given an array nums consisting of prime integers. Construct an array ans of the same length such that, for each index i, ans[i] | (ans[i] + 1) == nums[i]. Minimize each ans[i] independently. If no non-negative value satisfies the equation, set ans[i] to -1.

Examples
Input: [5,3,2]
Output: [4,2,0]
Hints

3314. Construct the Minimum Bitwise Array I

You are given an array `nums` consisting of prime integers. Construct an array `ans` of the same length such that, for each index `i`, `ans[i] | (ans[i] + 1) == nums[i]`. Minimize each `ans[i]` independently. If no non-negative value satisfies the equation, set `ans[i]` to `-1`.