*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.

For 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.
The first line contains two integers: *n* and *k* (2 ≤ *n* ≤ 500, 2 ≤ *k* ≤ 10<sup class="upper-index">12</sup>) — the number of people and the number of wins.

The second line contains *n* integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ *n*) — powers of the player. It's guaranteed that this line contains a valid permutation, i.e. all *a*<sub class="lower-index">*i*</sub> are distinct.
Games in the second sample:

3 plays with 1. 3 wins. 1 goes to the end of the line.

3 plays with 2. 3 wins. He wins twice in a row. He becomes the winner.
2 2
1 2
2 
4 2
3 1 2 4
3 
6 2
6 5 3 1 2 4
6 
2 10000000000
2 1
2
4 4
1 3 4 2
4 
2 2147483648
2 1
2
3 2
1 3 2
3 
3 3
1 2 3
3 
5 2
2 1 3 4 5
5 
10 2
7 10 5 8 9 3 4 6 1 2
10 
100 2
62 70 29 14 12 87 94 78 39 92 84 91 61 49 60 33 69 37 19 82 42 8 45 97 81 43 54 67 1 22 77 58 65 17 18 28 25 57 16 90 40 13 4 21 68 35 15 76 73 93 56 95 79 47 74 75 30 71 66 99 41 24 88 83 5 6 31 96 38 80 27 46 51 53 2 86 32 9 20 100 26 36 63 7 52 55 23 3 50 59 48 89 85 44 34 64 10 72 11 98
70 
4 10
2 1 3 4
4
10 2
1 2 3 4 5 6 7 8 9 10
10 
10 2
10 9 8 7 6 5 4 3 2 1
10 
4 1000000000000
3 4 1 2
4
100 10
19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43
91 
100 50
2 4 82 12 47 63 52 91 87 45 53 1 17 25 64 50 9 13 22 54 21 30 43 24 38 33 68 11 41 78 99 23 28 18 58 67 79 10 71 56 49 61 26 29 59 20 90 74 5 75 89 8 39 95 72 42 66 98 44 32 88 35 92 3 97 55 65 51 77 27 81 76 84 69 73 85 19 46 62 100 60 37 7 36 57 6 14 83 40 48 16 70 96 15 31 93 80 86 94 34
100 
2 1000000000000
1 2
2
5 2
1 4 3 5 2
4 
5 2
1 3 2 4 5
3 
4 1000000000000
3 1 2 4
4
4 2
1 3 2 4
3 
10 3
8 1 9 2 3 10 4 5 6 7
9 
5 2
2 1 4 3 5
4 
3 4294967297
2 1 3
3
4 4294967297
3 2 1 4
4
5 4294967298
3 2 1 4 5
5
10 4
5 4 7 1 2 9 3 6 8 10
9 
11 21474836489
10 1 2 3 4 5 6 7 8 9 11
11
from sys import stdin
from collections import Counter,defaultdict,deque
import sys
import math
import os
import operator
import random
from fractions import Fraction
import functools
import bisect
import itertools
from heapq import *
import copy

n,k = map(int,input().split())
arr = deque(map(int,input().split()))
powers = {i+1:arr[i] for i in range(n)}
i = 0
wins = 0
while wins!=k:
    winner = 1 if arr[1]>arr[0] else 0
    wins = 0
    while arr[winner]>arr[winner^1]:
        if winner == 0:
            x = arr.popleft()
            y = arr.popleft()
        else:
            y = arr.popleft()
            x = arr.popleft()
        arr.append(y)
        arr.appendleft(x)
        wins+=1
        if wins == k:
            for i in powers:
                if powers[i] == arr[winner]:
                    print(arr[winner])
            sys.exit()
        if wins>99999:
            for i in powers:
                if powers[i] == arr[winner]:
                    print(arr[winner])
            sys.exit()




'''
graph = [[1,0,0,0,0,0,1,1,0,'e'],
        [0,0,1,0,0,0,0,0,0,0],
        [1,0,1,0,0,1,1,0,1,1],
        [0,1,1,1,1,1,1,0,1,0],
        [0,0,0,0,0,0,0,1,1,0],
        [0,1,0,0,0,0,0,0,1,0],
        [0,1,1,1,1,1,0,0,0,0],
        [1,0,1,0,1,0,1,0,0,0],
        [1,0,1,1,0,0,0,1,1,1],
        ['s',0,0,0,0,0,0,1,1,0]]

kShift = [[0,1],[0,-1],[1,0],[-1,0]]

def floodfill(graph,x,y,new_color,old_color):
    if 0<=x<len(graph) and 0<=y<len(graph[0]) and graph[x][y] == old_color:
        graph[x][y] = new_color
        floodfill(graph,x,y+1,new_color,old_color)
        floodfill(graph,x,y-1,new_color,old_color)
        floodfill(graph,x+1,y,new_color,old_color)
        floodfill(graph,x-1,y,new_color,old_color)

floodfill(graph,4,2,5,0)
for i in graph:
    print(i)











'''
