{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"Gamal thinks he is more clever than Ali, so Ali gave him a hard challenge and told him that if he can solve it, he will admit that he is more clever than him.\n\u003cbr\u003e\u003cbr\u003e\nThe challenge is:\u003cbr\u003e\nAli will give Gamal a sequence of $n$ numbers, and an integer $p$. Gamal is asked to find another integer $s$ such that exactly $p$ elements are smaller or equal to $s$. $(1 \\le s \\le 10^9)$\n\u003cbr\u003e\u003cbr\u003e\nGamal wants your help with that challenge so he can prove he is more clever than Ali, can you help him?\n\n\u003cbr\u003e\u003cbr\u003e\n\u003ch5\u003eNOTE:\u003c/h5\u003e\nThere are two cases, $p$\u003d0 and otherwise.\u003cbr\u003e\n$p$ can be equal to 0, in that case, we want a number smaller than anything in the array (This can be a problem if the first number in the array is 1, which lets you output 0, and that is outside the possible range, so -1).\n\u003cbr\u003e\u003cbr\u003e\nOtherwise we want a number which has $p$ elements less than or equal to it. The equal might be a problem, as smaller is easy to get, make sure if it is even possible to get $p$ elements smaller than or equal, as the number you got itself might be duplicated in the array. If not, print -1, else you can get that number as there is no duplication and there will be $p$ elements smaller than or equal to the number. \u003cbr\u003e\u003cbr\u003e\nHints:\u003cbr\u003e\n-If $p$ is $n$, then you want a number which has $n$ elements less than or equal to it, which means a number greater than or equal to the max, but be careful of the range and not to exceed $10^9$.\u003cbr\u003e\n-Think of sorting and using indexes to help you.\u003cbr\u003e\n-Note that you are outputting a number, not an index, so you want the value of an element.\n\n\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eLast hint:\u003c/b\u003e\u003cbr\u003e\n\u003cli\u003e$p$\u003d0 case must be handled first. The description is in the note above. It has two cases in it, if the minimum value in the array is 1, or if it is not. Handle these two cases if $p$\u003d0.\u003cbr\u003e\u003cbr\u003e\n\u003cli\u003eSort the array, now at index $p$ there is an element, which we are sure there are $p$ elements less than or equal to it, as the array is sorted. Our issue lies if the value at index $p$ is duplicated. You need to check that. If it is duplicated that rises an issue as you can not get an element that satisfies the condition. If not, then that value sounds good."}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains two integers $n,p$ $(1 \\le n \\le 2.10^5, 0 \\le p \\le n)$.\n\u003cbr\u003e\u003cbr\u003e\nThe second line contains $n$ space-separated integers $a_1,a_2,...,a_n$ $(1 \\le a_i \\le 10^9)$ - the elements of the sequence."}},{"title":"Output","value":{"format":"HTML","content":"Output an integer $s$ $(1 \\le s \\le 10^9)$ which holds the condition that exactly $p$ elements $\\le s$, or output $-1$ if no such $s$ exists.\n\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eNote: there can be multiple valid $s$, so output any of them. You don\u0027t have to get the same output as the samples.\u003c/b\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n7 4\n7 2 5 8 1 10 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n7 4\n7 2 5 5 1 10 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 3","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n1 0\n1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 4","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n1 0\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}