<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> representing the contents of a <b>pile</b>, where <code>nums[0]</code> is the topmost element of the pile.</p>
<p>In one move, you can perform <strong>either</strong> of the following:</p>
<ul>
<li>If the pile is not empty, <strong>remove</strong> the topmost element of the pile.</li>
<li>If there are one or more removed elements, <strong>add</strong> any one of them back onto the pile. This element becomes the new topmost element.</li>
</ul>
<p>You are also given an integer <code>k</code>, which denotes the total number of moves to be made.</p>
<p>Return <em>the <strong>maximum value</strong> of the topmost element of the pile possible after <strong>exactly</strong></em><code>k</code><em>moves</em>. In case it is not possible to obtain a non-empty pile after <code>k</code> moves, return <code>-1</code>.</p>