{"raw_statement":[{"iden":"statement","content":"Alice and Bob got very bored during a long car trip so they decided to play a game. From the window they can see cars of different colors running past them. Cars are going one after another.\n\nThe game rules are like this. Firstly Alice chooses some color _A_, then Bob chooses some color _B_ (_A_ ≠ _B_). After each car they update the number of cars of their chosen color that have run past them. Let's define this numbers after _i_\\-th car _cnt__A_(_i_) and _cnt__B_(_i_).\n\n*   If _cnt__A_(_i_) > _cnt__B_(_i_) for every _i_ then the winner is Alice.\n*   If _cnt__B_(_i_) ≥ _cnt__A_(_i_) for every _i_ then the winner is Bob.\n*   Otherwise it's a draw.\n\nBob knows all the colors of cars that they will encounter and order of their appearance. Alice have already chosen her color _A_ and Bob now wants to choose such color _B_ that he will win the game (draw is not a win). Help him find this color.\n\nIf there are multiple solutions, print any of them. If there is no such color then print _\\-1_."},{"iden":"input","content":"The first line contains two integer numbers _n_ and _A_ (1 ≤ _n_ ≤ 105, 1 ≤ _A_ ≤ 106) – number of cars and the color chosen by Alice.\n\nThe second line contains _n_ integer numbers _c_1, _c_2, ..., _c__n_ (1 ≤ _c__i_ ≤ 106) — colors of the cars that Alice and Bob will encounter in the order of their appearance."},{"iden":"output","content":"Output such color _B_ (1 ≤ _B_ ≤ 106) that if Bob chooses it then he will win the game. If there are multiple solutions, print any of them. If there is no such color then print _\\-1_.\n\nIt is guaranteed that if there exists any solution then there exists solution with (1 ≤ _B_ ≤ 106)."},{"iden":"examples","content":"Input\n\n4 1\n2 1 4 2\n\nOutput\n\n2\n\nInput\n\n5 2\n2 2 4 5 3\n\nOutput\n\n\\-1\n\nInput\n\n3 10\n1 2 3\n\nOutput\n\n4"},{"iden":"note","content":"Let's consider availability of colors in the first example:\n\n*   _cnt_2(_i_) ≥ _cnt_1(_i_) for every _i_, and color 2 can be the answer.\n*   _cnt_4(2) < _cnt_1(2), so color 4 isn't the winning one for Bob.\n*   All the other colors also have _cnt__j_(2) < _cnt_1(2), thus they are not available.\n\nIn the third example every color is acceptable except for 10."}],"translated_statement":[{"iden":"statement","content":"Alice 和 Bob 在一次漫长的车程中感到非常无聊，于是决定玩一个游戏。从车窗望去，他们可以看到不同颜色的汽车依次驶过。\n\n游戏规则如下：首先 Alice 选择一种颜色 #cf_span[A]，然后 Bob 选择另一种颜色 #cf_span[B]（#cf_span[A ≠ B]）。每经过一辆车，他们都会更新自己所选颜色的汽车数量。定义经过第 #cf_span[i] 辆车后，Alice 和 Bob 所选颜色的计数分别为 #cf_span[cntA(i)] 和 #cf_span[cntB(i)]。\n\nBob 知道他们将遇到的所有汽车的颜色及其出现顺序。Alice 已经选择了她的颜色 #cf_span[A]，现在 Bob 希望选择一个颜色 #cf_span[B]，使得他能赢得游戏（平局不算赢）。请帮他找到这样一个颜色。\n\n如果有多个解，请输出任意一个。如果没有这样的颜色，请输出 _-1_。\n\n第一行包含两个整数 #cf_span[n] 和 #cf_span[A]（#cf_span[1 ≤ n ≤ 105, 1 ≤ A ≤ 106]）——汽车总数和 Alice 选择的颜色。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[c1, c2, ..., cn]（#cf_span[1 ≤ ci ≤ 106]）——表示 Alice 和 Bob 按出现顺序将遇到的汽车颜色。\n\n请输出一个颜色 #cf_span[B]（#cf_span[1 ≤ B ≤ 106]），使得如果 Bob 选择它，他就能赢得游戏。如果有多个解，输出任意一个；如果没有这样的颜色，则输出 _-1_。\n\n题目保证：如果存在解，则一定存在一个满足 (#cf_span[1 ≤ B ≤ 106]) 的解。\n\n让我们分析第一个例子中颜色的可用性：\n\n在第三个例子中，除了 #cf_span[10] 之外的所有颜色都是可接受的。"},{"iden":"input","content":"第一行包含两个整数 #cf_span[n] 和 #cf_span[A]（#cf_span[1 ≤ n ≤ 105, 1 ≤ A ≤ 106]）——汽车总数和 Alice 选择的颜色。第二行包含 #cf_span[n] 个整数 #cf_span[c1, c2, ..., cn]（#cf_span[1 ≤ ci ≤ 106]）——表示 Alice 和 Bob 按出现顺序将遇到的汽车颜色。"},{"iden":"output","content":"请输出一个颜色 #cf_span[B]（#cf_span[1 ≤ B ≤ 106]），使得如果 Bob 选择它，他就能赢得游戏。如果有多个解，输出任意一个；如果没有这样的颜色，则输出 _-1_。题目保证：如果存在解，则一定存在一个满足 (#cf_span[1 ≤ B ≤ 106]) 的解。"},{"iden":"examples","content":"输入\n4 1\n2 1 4 2\n输出\n2\n\n输入\n5 2\n2 2 4 5 3\n输出\n-1\n\n输入\n3 10\n1 2 3\n输出\n4"},{"iden":"note","content":"让我们分析第一个例子中颜色的可用性：对每个 #cf_span[i]，都有 #cf_span[cnt2(i) ≥ cnt1(i)]，因此颜色 #cf_span[2] 可以作为答案。而 #cf_span[cnt4(2) < cnt1(2)]，所以颜色 #cf_span[4] 不是 Bob 的获胜选择。其他所有颜色也都有 #cf_span[cntj(2) < cnt1(2)]，因此均不可用。在第三个例子中，除了 #cf_span[10] 之外的所有颜色都是可接受的。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of cars.  \nLet $ A \\in \\mathbb{Z}^+ $ be Alice’s chosen color.  \nLet $ C = (c_1, c_2, \\dots, c_n) $ be the sequence of car colors, where $ c_i \\in \\mathbb{Z}^+ $.  \n\nFor any color $ x \\in \\mathbb{Z}^+ $, define the cumulative count function:  \n$$\n\\text{cnt}_x(i) = \\left| \\{ j \\in \\{1, \\dots, i\\} \\mid c_j = x \\} \\right|\n$$\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. $ 1 \\leq A \\leq 10^6 $  \n3. $ 1 \\leq c_i \\leq 10^6 $ for all $ i \\in \\{1, \\dots, n\\} $  \n4. $ B \\neq A $, and $ B \\in \\{1, \\dots, 10^6\\} $\n\n**Objective**  \nFind a color $ B \\neq A $ such that:  \n$$\n\\text{cnt}_B(n) > \\text{cnt}_A(n)\n$$  \nIf multiple such $ B $ exist, output any. If none exists, output $-1$.","simple_statement":null,"has_page_source":false}