#C6276. Find the Number with an Odd Occurrence

    ID: 50018 Type: Default 1000ms 256MiB

Find the Number with an Odd Occurrence

Find the Number with an Odd Occurrence

You are given an array of n integers. In this array, every integer appears an even number of times except for one integer that appears an odd number of times. Your task is to find and output this integer.

You can solve this problem efficiently using the XOR operation. Recall that the XOR operator (\(\oplus\)) has the property that \(a \oplus a = 0\) and \(a \oplus 0 = a\). Therefore, by performing XOR over all elements, pairs of identical numbers will cancel out, leaving only the number that occurs an odd number of times.

inputFormat

The input is read from stdin and consists of two parts:

  1. An integer n, the number of elements in the array.
  2. n space-separated integers representing the array.

outputFormat

Output to stdout a single integer which is the number that appears an odd number of times in the array.

## sample
5
1 2 3 2 1
3