Single Non-Duplicate

HARD · C · 3000ms

During a stress test, every sensor ID logs twice except ONE faulty sensor that logs only once — Nusrat must find it using O(1) extra memory, no arrays allowed. Read N integers where every value appears EXACTLY TWICE except one value which appears exactly once. Find that value in O(N) time and O(1) extra space using XOR (do not use a hashmap/array counting approach).

Input

First line N (odd), second line N integers.

Output

The single non-duplicate value.

Constraints

1 ≤ N ≤ 2×10^5, N is odd

Sample Input

5
4 1 2 1 2

Sample Output

4
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

Single Non-Duplicate · DIU ContestHub