Find XOR Beauty

Define the XOR beauty of an array as the XOR over all triplets (i, j, k) of (nums[i] | nums[j]) & nums[k], where indices may repeat. Despite the complex definition, this expression simplifies to a single XOR of all elements in the array. Compute it efficiently.

Examples
Input: [1,4]
Output: 5
Hints

Find XOR Beauty

Define the XOR beauty of an array as the XOR over all triplets `(i, j, k)` of `(nums[i] | nums[j]) & nums[k]`, where indices may repeat. Despite the complex definition, this expression simplifies to a single XOR of all elements in the array. Compute it efficiently.