Raise a single number Introduction

Suppose you want to compute the tail maxima of a list of numbers, that is, the maximum of each nonempty suffix.
One way to do it is to repeatedly choose one number and replace it by a higher number occurring after it, until this is not possible anymore.
In this challenge, your task is to perform one step of this algorithm.

The task

Your input is a list of integers L, which may be empty.
Your output shall be the list L where exactly one number Li has been replaced by another Lj, where Li &lt; Lj and i &lt; j.

In other words, you shall replace one number with a higher number that occurs after it.

You can choose i and j freely among all valid pairs, and the choice can be nondeterministic.

If such i and j do not exist (i.e. L is non-increasing), your output shall be L unchanged.

Example

Consider the input L = [ 3, 1, 4, -1, 2 ].
The possible operations are to replace 3 by 4, replace 1 by 4, replace 1 by 2, or replace -1 by 2.
Thus the possible outputs are:

 [  3 ,   1 ,   4 ,  -1 ,   2 ]
 ------------------------------
 [( 4),   1 ,(  4),  -1 ,   2 ]
 [  3 ,(  4),(  4),  -1 ,   2 ]
 [  3 ,(  2),   4 ,  -1 ,(  2)]
 [  3 ,   1 ,   4 ,(  2),(  2)]


If you repeat the operation enough times, the end result will be [4,4,4,2,2], which is precisely the list of tail maxima of L.

Rules and scoring

You can write a full program or a function.
In the latter case, you can modify the input in place instead of returning a new array, if your language allows that.
Input and output formats are flexible within reason.

The lowest byte count wins.

Test cases

All possible outputs are shown.

[] -&gt; []
[1] -&gt; [1]
[1,2] -&gt; [2,2]
[2,1] -&gt; [2,1]
[4,4,4,4] -&gt; [4,4,4,4]
[-1,-3,-10] -&gt; [-1,-3,-10]
[1,3,10] -&gt; [3,3,10] [10,3,10] [1,10,10]
[1,1,2,1] -&gt; [2,1,2,1] [1,2,2,1]
[998,64,2,-94,-789] -&gt; [998,64,2,-94,-789]
[998,2,64,-94,-789] -&gt; [998,64,64,-94,-789]
[3,1,4,-1,2] -&gt; [4,1,4,-1,2] [3,4,4,-1,2] [3,2,4,-1,2] [3,1,4,2,2]
[-1,4,0,4,7,2,3] -&gt; [4,4,0,4,7,2,3] [0,4,0,4,7,2,3] [-1,4,4,4,7,2,3] [7,4,0,4,7,2,3] [-1,7,0,4,7,2,3] [-1,4,7,4,7,2,3] [-1,4,0,7,7,2,3] [2,4,0,4,7,2,3] [-1,4,2,4,7,2,3] [3,4,0,4,7,2,3] [-1,4,3,4,7,2,3] [-1,4,0,4,7,3,3]
[3542,-12311,7662,1672,6081] -&gt; [7662,-12311,7662,1672,6081] [3542,7662,7662,1672,6081] [3542,1672,7662,1672,6081] [6081,-12311,7662,1672,6081] [3542,6081,7662,1672,6081] [3542,-12311,7662,6081,6081]
JavaScript (ES6), 41 40 39 38 bytes

Saved a byte thanks to @Neil, another thanks to @user81655

x=&gt;x.map(c=&gt;c&lt;x[++i]&gt;d?x[d=i]:c,d=i=0)


Just when it seems reduceRight might finally have a chance, .map shows up yet again...