PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000096. Phần tử xuất hiện đúng một lần (Single Element in a Sorted Array)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Phần tử xuất hiện đúng một lần (Single Element in a Sorted Array)

Single Element in a Sorted Array

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

In a sorted integer array, exactly one value occurs once and every other value occurs exactly twice. Find the unique singleton value.

Input

The first line contains odd nn; the second contains the nn sorted integers.

Output

Print the singleton value.

Subtasks

  • Subtask 1 (20 points): 1≤n≤211\le n\le 21; nn is odd; 0≤ai≤1050\le a_i\le10^5; non-decreasing; exactly one value occurs once, all others exactly twice.
  • Subtask 2 (30 points): 1≤n≤19991\le n\le 1999; nn is odd; 0≤ai≤1050\le a_i\le10^5; non-decreasing; exactly one value occurs once, all others exactly twice.
  • Subtask 3 (50 points): 1≤n≤999991\le n\le 99999; nn is odd; 0≤ai≤1050\le a_i\le10^5; non-decreasing; exactly one value occurs once, all others exactly twice.

Examples

Input

9
1 1 2 3 3 4 4 8 8

Output

2

Explanation

11, 33, 44, and 88 each appear twice; only 22 occurs once. Output 2.