You are given an array *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> consisting of *n* integers, and an integer *k*. You have to split the array into exactly *k* non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the maximum integer over the *k* obtained minimums. What is the maximum possible integer you can get?

Definitions of subsegment and array splitting are given in notes.
The first line contains two integers *n* and *k* (1 ≤ *k* ≤ *n* ≤  10<sup class="upper-index">5</sup>) — the size of the array *a* and the number of subsegments you have to split the array to.

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> ( - 10<sup class="upper-index">9</sup>  ≤  *a*<sub class="lower-index">*i*</sub> ≤  10<sup class="upper-index">9</sup>).
A subsegment [*l*,  *r*] (*l* ≤ *r*) of array *a* is the sequence *a*<sub class="lower-index">*l*</sub>,  *a*<sub class="lower-index">*l* + 1</sub>,  ...,  *a*<sub class="lower-index">*r*</sub>.

Splitting of array *a* of *n* elements into *k* subsegments [*l*<sub class="lower-index">1</sub>, *r*<sub class="lower-index">1</sub>], [*l*<sub class="lower-index">2</sub>, *r*<sub class="lower-index">2</sub>], ..., [*l*<sub class="lower-index">*k*</sub>, *r*<sub class="lower-index">*k*</sub>] (*l*<sub class="lower-index">1</sub> = 1, *r*<sub class="lower-index">*k*</sub> = *n*, *l*<sub class="lower-index">*i*</sub> = *r*<sub class="lower-index">*i* - 1</sub> + 1 for all *i* &gt; 1) is *k* sequences (*a*<sub class="lower-index">*l*<sub class="lower-index">1</sub></sub>, ..., *a*<sub class="lower-index">*r*<sub class="lower-index">1</sub></sub>), ..., (*a*<sub class="lower-index">*l*<sub class="lower-index">*k*</sub></sub>, ..., *a*<sub class="lower-index">*r*<sub class="lower-index">*k*</sub></sub>).

In the first example you should split the array into subsegments [1, 4] and [5, 5] that results in sequences (1, 2, 3, 4) and (5). The minimums are *min*(1, 2, 3, 4) = 1 and *min*(5) = 5. The resulting maximum is *max*(1, 5) = 5. It is obvious that you can't reach greater result.

In the second example the only option you have is to split the array into one subsegment [1, 5], that results in one sequence ( - 4,  - 5,  - 3,  - 2,  - 1). The only minimum is *min*( - 4,  - 5,  - 3,  - 2,  - 1) =  - 5. The resulting maximum is  - 5.
5 2
1 2 3 4 5
5
5 1
-4 -5 -3 -2 -1
-5
10 2
10 9 1 -9 -7 -9 3 8 -10 5
10
10 4
-8 -1 2 -3 9 -8 4 -3 5 9
9
1 1
504262064
504262064
3 3
-54481850 -878017339 -486296116
-54481850
2 2
-333653905 224013643
224013643
14 2
-14 84 44 46 -75 -75 77 -49 44 -82 -74 -51 -9 -50
-14
88 71
-497 -488 182 104 40 183 201 282 -384 44 -29 494 224 -80 -491 -197 157 130 -52 233 -426 252 -61 -51 203 -50 195 -442 -38 385 232 -243 -49 163 340 -200 406 -254 -29 227 -194 193 487 -325 230 146 421 158 20 447 -97 479 493 -130 164 -471 -198 -330 -152 359 -554 319 544 -444 235 281 -467 337 -385 227 -366 -210 266 69 -261 525 526 -234 -355 177 109 275 -301 7 -41 553 -284 540
553
39 1
676941771 -923780377 -163050076 -230110947 -208029500 329620771 13954060 158950156 -252501602 926390671 -678745080 -921892226 -100127643 610420285 602175224 -839193819 471391946 910035173 777969600 -736144413 -489685522 60986249 830784148 278642552 -375298304 197973611 -354482364 187294011 636628282 25350767 636184407 -550869740 53830680 -42049274 -451383278 900048257 93225803 877923341 -279506435
-923780377
3 2
1 5 3
3
5 2
1 2 5 4 3
3
3 2
1 3 2
2
3 2
1 3 1
1
5 3
-2 -2 -2 -2 -2
-2
5 2
1 2 3 5 4
4
5 2
1 1 11 1 1
1
3 3
3 8 4
8
6 3
4 3 1 5 6 2
6
2 1
1 2
1
5 2
2 5 4 3 1
2
5 2
-1 1 5 4 3
3
5 2
5 2 1 9 3
5
2 1
1000000000 1000000000
1000000000
1 1
1000000000
1000000000
5 2
1 5 3 4 1
1
3 2
-1000000000 -1000000000 -1000000000
-1000000000
2 2
5 2
5
7 3
1 1 1 10 1 1 1
10
9 3
1 2 1 1 5 1 1 1 2
5
9 3
2 2 2 2 9 2 2 2 2
9
3 3
-1000000000 -1000000000 -1000000000
-1000000000
import sys

nk = list(map(int,input().split()))
a = list(map(int,input().split()))

a.sort()

if(nk[2]>1):
    print(a[-1])
else:
    print(a[0])