You are making things far too hard. Rather than successively taking out one element at a time, and doing a check, you can simply take a one-time bitwise OR of all elements: If there is an element that is the result of the bitwise OR on all others, then that element will also be the bitwise OR of all elements, including itself!
Here is why:
Assuming that there is indeed one such element, then for any bit position it will be true that the bit of the element you are looking for is a $1$ if and only if at least one of the bits of the other elements is a $1$.
So, it is impossible to have that bit being a $1$ when the corresponding bits of the other numbers are all $0$, and it is also impossible for that bit being a $0$ when there is at least one corresponding bit that's a $1$.
That means that if we OR the value of the bit of the element we are looking for with all the corresponding bits from all the other elements, we get the value of the first bit.
Therefore, the value of that bit equals the value of the OR of all the bits for that position, and thus we can simply take the OR of all bits for that position to find the value of the bit we want.
In other words, you can simply take the bitwise OR for all elements, and then see which of the elements equals the result of that: that's the element you are looking for.
So notice that with numbers $1$ through $6$ there is no element that is the result of the bitwise OR on all other elements, because for every position there are at least two $1$'s, and hence the bitwise or of any fice elements will give you $111$, i.e. $7$.
However, if you take numbers $1$ through $7$, then not only is $7$ the bitwise OR of $1$ through $6$, but also of $1$ through $7$, and as I just explained, it has to be that way, again assuming there is such an element in the first place.