#BST0000007. Predecessor trong BST (Inorder Predecessor in a BST)

Predecessor trong BST (Inorder Predecessor in a BST)

Inorder Predecessor in a BST

Source: Phuoc Hung OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Build a BST from a1,a2,…,ana_1,a_2,\ldots,a_n in insertion order. Duplicate insertion keys are ignored.

A key xx is guaranteed to exist in the tree. The strict inorder predecessor of xx is the largest stored key that is smaller than xx.

Find this strict inorder predecessor. If no stored key is smaller than xx, the predecessor does not exist.

Input

The first line contains nn.

The second line contains nn signed integers a1,a2,…,ana_1,a_2,\ldots,a_n in insertion order.

The third line contains xx.

Output

Print the predecessor key if it exists; otherwise print NONE.

Subtasks

Subtask 1 (20 points): 1≤n≤201\le n\le 20.

Subtask 2 (30 points): 1≤n≤50001\le n\le 5000.

Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000.

In all subtasks, aia_i and xx are signed 64-bit integers, duplicate insertion keys are ignored, and xx is guaranteed to belong to the resulting BST.

Examples

Input

7
8 3 10 1 6 14 4
6

Output

4

Explanation

The stored keys smaller than 66 are 1,3,41,3,4. The largest of them is 44, so the strict inorder predecessor of 66 is 44.