#C5204. Single Number

    ID: 48828 Type: Default 1000ms 256MiB

Single Number

Single Number

You are given a list of integers where every element appears exactly twice except for one element that appears only once. Your task is to find and output this unique element.

The problem can be solved by leveraging the properties of the XOR operation. Recall that for any integer a,
\(a \oplus a = 0\) and \(a \oplus 0 = a\). Hence, by XOR-ing all the numbers, the numbers that appear in pairs cancel out, leaving only the unique number.

Note: The first line of input specifies the number of elements, n, and the second line contains the n integers separated by spaces.

inputFormat

The input consists of two lines:

  • The first line contains a single integer n (1 ≤ n ≤ 105), which is the number of elements in the list.
  • The second line contains n space-separated integers.

outputFormat

Output a single integer representing the element that appears only once in the list.

## sample
5
4 1 2 1 2
4