A - 待ち合わせ場所 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

一直線の通りに N 棟のビルが建っており、 i 番目のビルは座標 X_i の位置にあります。

高橋君は友人と「 K 番目のビルの座標から 1 だけ小さい地点、すなわち座標 (X_K - 1) の地点で待ち合わせをしよう」と約束しました。

高橋君が向かうべき待ち合わせ地点の座標を求めてください。

制約

  • 1 \leq N \leq 10^5
  • 1 \leq K \leq N
  • -10^{18} \leq X_i \leq 10^{18}
  • 入力はすべて整数である

入力

N K
X_1
X_2
:
X_N
  • 1 行目には、ビルの総数を表す整数 N と、目印となるビルの番号 K がスペース区切りで与えられる。
  • 続く N 行にわたって、各ビルの座標が与えられる。
  • 1 + i 行目には、 i 番目のビルの座標である整数 X_i が与えられる。

出力

高橋君が向かうべき地点の座標を整数で 1 行に出力してください。


入力例 1

3 2
10
20
30

出力例 1

19

入力例 2

4 4
-5
0
7
12

出力例 2

11

入力例 3

8 6
-1000
-500
0
250
999
12345
54321
100000

出力例 3

12344

入力例 4

15 11
500
-200
1300
42
999999
-999999
0
17
250
-1
888888888888
76
-3456
123456789
5

出力例 4

888888888887

入力例 5

1 1
-1000000000000000000

出力例 5

-1000000000000000001

Score : 200 pts

Problem Statement

There are N buildings along a straight street, and the i-th building is located at coordinate X_i.

Takahashi made a promise with his friend: "Let's meet at the point that is 1 less than the coordinate of the K-th building, namely at coordinate (X_K - 1)."

Find the coordinate of the meeting point where Takahashi should head to.

Constraints

  • 1 \leq N \leq 10^5
  • 1 \leq K \leq N
  • -10^{18} \leq X_i \leq 10^{18}
  • All inputs are integers

Input

N K
X_1
X_2
:
X_N
  • The first line contains an integer N representing the total number of buildings and the number K of the landmark building, separated by a space.
  • The following N lines give the coordinate of each building.
  • The (1 + i)-th line contains the integer X_i, which is the coordinate of the i-th building.

Output

Print the coordinate of the point where Takahashi should head to, as an integer on a single line.


Sample Input 1

3 2
10
20
30

Sample Output 1

19

Sample Input 2

4 4
-5
0
7
12

Sample Output 2

11

Sample Input 3

8 6
-1000
-500
0
250
999
12345
54321
100000

Sample Output 3

12344

Sample Input 4

15 11
500
-200
1300
42
999999
-999999
0
17
250
-1
888888888888
76
-3456
123456789
5

Sample Output 4

888888888887

Sample Input 5

1 1
-1000000000000000000

Sample Output 5

-1000000000000000001