{"raw_statement":[{"iden":"statement","content":"_n_ people are standing in a line to play table tennis. At first, the first two players in the line play a game. Then the loser goes to the end of the line, and the winner plays with the next person from the line, and so on. They play until someone wins _k_ games in a row. This player becomes the winner.\n\nFor each of the participants, you know the power to play table tennis, and for all players these values are different. In a game the player with greater power always wins. Determine who will be the winner."},{"iden":"input","content":"The first line contains two integers: _n_ and _k_ (2 ≤ _n_ ≤ 500, 2 ≤ _k_ ≤ 1012) — the number of people and the number of wins.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_ (1 ≤ _a__i_ ≤ _n_) — powers of the player. It's guaranteed that this line contains a valid permutation, i.e. all _a__i_ are distinct."},{"iden":"output","content":"Output a single integer — **power** of the winner."},{"iden":"examples","content":"Input\n\n2 2\n1 2\n\nOutput\n\n2 \n\nInput\n\n4 2\n3 1 2 4\n\nOutput\n\n3 \n\nInput\n\n6 2\n6 5 3 1 2 4\n\nOutput\n\n6 \n\nInput\n\n2 10000000000\n2 1\n\nOutput\n\n2"},{"iden":"note","content":"Games in the second sample:\n\n3 plays with 1. 3 wins. 1 goes to the end of the line.\n\n3 plays with 2. 3 wins. He wins twice in a row. He becomes the winner."}],"translated_statement":[{"iden":"statement","content":"#cf_span[n] 个人排成一列玩乒乓球。最初，队列中的前两名玩家进行一场比赛。然后输家走到队列末尾，赢家与队列中的下一位玩家比赛，依此类推。他们继续比赛，直到有人连续赢得 #cf_span[k] 场比赛，该玩家成为胜者。\n\n对于每位参与者，你知道他们的乒乓球实力，且所有玩家的实力值互不相同。在比赛中，实力更强的玩家总是获胜。请确定胜者的实力。\n\n第一行包含两个整数：#cf_span[n] 和 #cf_span[k]（#cf_span[2 ≤ n ≤ 500]，#cf_span[2 ≤ k ≤ 1012]）——人数和所需的连续胜场数。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an]（#cf_span[1 ≤ ai ≤ n]）——每位玩家的实力。保证该行是一个有效排列，即所有 #cf_span[ai] 互不相同。\n\n请输出一个整数——胜者的 *实力*。\n\n第二个样例中的比赛过程：\n\n#cf_span[3] 与 #cf_span[1] 比赛。#cf_span[3] 获胜。#cf_span[1] 移动到队列末尾。\n\n#cf_span[3] 与 #cf_span[2] 比赛。#cf_span[3] 获胜。他连续赢了两次，成为胜者。\n\n"},{"iden":"input","content":"第一行包含两个整数：#cf_span[n] 和 #cf_span[k]（#cf_span[2 ≤ n ≤ 500]，#cf_span[2 ≤ k ≤ 1012]）——人数和所需的连续胜场数。第二行包含 #cf_span[n] 个整数 #cf_span[a1, a2, ..., an]（#cf_span[1 ≤ ai ≤ n]）——每位玩家的实力。保证该行是一个有效排列，即所有 #cf_span[ai] 互不相同。"},{"iden":"output","content":"请输出一个整数——胜者的 *实力*。"},{"iden":"examples","content":"输入2 21 2输出2 输入4 23 1 2 4输出3 输入6 26 5 3 1 2 4输出6 输入2 100000000002 1输出2"},{"iden":"note","content":"第二个样例中的比赛过程：#cf_span[3] 与 #cf_span[1] 比赛。#cf_span[3] 获胜。#cf_span[1] 移动到队列末尾。#cf_span[3] 与 #cf_span[2] 比赛。#cf_span[3] 获胜。他连续赢了两次，成为胜者。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, k \\in \\mathbb{Z} $ with $ 2 \\leq n \\leq 500 $, $ 2 \\leq k \\leq 10^{12} $.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a permutation of $ \\{1, 2, \\dots, n\\} $, representing the powers of players in initial line order.\n\n**Constraints**  \nAll $ a_i $ are distinct integers in $ [1, n] $.\n\n**Objective**  \nSimulate a tournament where:  \n- The first two players $ a_1 $ and $ a_2 $ compete.  \n- The loser moves to the end of the line; the winner stays and plays the next player.  \n- The process continues until one player wins $ k $ **consecutive** games.  \n- The player with higher power always wins.  \n\nOutput the **power** of the first player to achieve $ k $ consecutive wins.  \n\n**Note**: If $ k > n-1 $, the player with maximum power in $ A $ will eventually win $ k $ consecutive games after defeating all others.","simple_statement":null,"has_page_source":false}