[Question]
  [
*Inspired by [a question](https://stackoverflow.com/q/43640022/2586922) over at Stack Overflow. The title here is entirely my fault.*
---
## The challenge
Given a list of positive integers containing at least two entries, replace each number by the minimum of all entries excluding itself.
## Test cases
```
[4 3 2 5]    ->  [2 2 3 2]
[4 2 2 5]    ->  [2 2 2 2]
[6 3 5 5 8]  ->  [3 5 3 3 3]
[7 1]        ->  [1 7]
[9 9]        ->  [9 9]
[9 8 9]      ->  [8 9 8]
```
## Rules
The algorithm should theoretically work for any input size (greater than one) and values (positive integers). It's accepted if the program is limited by time, memory or data types and so only works for numbers up to a given value, or for input size up to a given value.
[Programs or functions](http://meta.codegolf.stackexchange.com/a/2422/36398) are allowed, in any [programming language](http://meta.codegolf.stackexchange.com/a/2073/36398). [Standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
Input can be taken by any [reasonable means](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods); and with any format. Same for output. Input and output formats may be different.
Shortest code in bytes wins.
  
[Answer]
# [Python 2](https://docs.python.org/2/), 41 bytes
```
lambda l:[sorted(l)[x==min(l)]for x in l]
```
[Try it online!](https://tio.run/nexus/python2#LcxNCoAgEAXgdZ1ilgaz6b8ET2IujBIEszAX3d7GiIE335vFGLEkp4910@C4vM8Q9425Sj5CHNaTlDkDPGA9OJWy437HXKXssMUGe4Wk5tdAt55mIo9YU844fznRVrwsrmB9BMPynyqlFw "Python 2 – TIO Nexus")
For each element `x` we check whether `x==min(l)`. If not, this is `False`, which is treated as `0` when used as a list index into `sorted(l)`, giving the smallest element. Otherwise, it's `True` aka `1`, giving the second-smallest element, since that element itself is smallest and should be ignored.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~9~~ ~~6~~ 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
~~JḟÐ€`ị⁸Ṃ€~~
~~ṙJṖ€Ṃ€~~
ṙJṖ«/     argument: 1D array (z)
 J        [1,2,3,...,len(z)]
ṙ         rotate z by each of the above amount (current array is 2D)
  Ṗ       remove the last array
   «/     reduce by [impliclitly vectorized] minimum
```
[Try it online!](https://tio.run/nexus/jelly#@/9w50yvhzunHVqt/////2gTHSMgNI0FAA "Jelly – TIO Nexus")
[Verify all of them at once!](https://tio.run/nexus/jelly#@/9w50yvhzunHVqtz3W4/VHTmv///0dHm@gY6xjpmMbqAFlGUJYZUMwUCC2AbHMdQyBpqWMJJi2AdCwA "Jelly – TIO Nexus") (slightly modified)
I'm pretty sure Dennis can out-golf this.
## How it works
The algorithm is rather convoluted. Let us observe what this does to `[4,2,2,5]`.
Firstly, we use `J` to obtain `[1,2,3,4]`. Note that Jelly uses 1-indexing.
Then, we see `ṙ`. It takes two arguments: an array and an integer. It rotates the array to the left by an amount specified by the integer. Here, `ṙ` would see `[4,2,2,5]` on its left and `[1,2,3,4]` on its right (more about how this works can be found in the [tutorial](https://github.com/DennisMitchell/jelly/wiki/Tutorial#42monadic-chains)). In Jelly, commands implicitly vectorize. Therefore, this command will be performed over each individual element on the right, which is why we would create a 2D array:
Therefore, `[4,2,2,5]ṙ[1,2,3,4]` becomes `[[4,2,2,5]ṙ1,[4,2,2,5]ṙ2,[4,2,2,5]ṙ3,[4,2,2,5]ṙ4]`, which becomes:
```
[[2,2,5,4],
 [2,5,4,2],
 [5,4,2,2],
 [4,2,2,5]]
```
Notice that the original elements are on the last row, since in that row we rotated to the left by an amount equal to the length of the array, which is why we use `Ṗ` next to remove that row, so that the columns are the collections of the elements of the array which are not at the current index:
```
[[2,2,5,4],
 [2,5,4,2],
 [5,4,2,2]]
```
The following operation, `«/`, is also quite convoluted. Firstly, `«` returns the minimum of the two numbers it sees on its left and on its right. For example, `5«3` returns `3`. Now, if the two arguments are arrays, then it would vectorize as I have said above. What this means it that `[1,5,2,3]«[4,1,5,2]` would become `[1«4,5«1,2«5,3«2]` which is `[1,1,2,2]`. Now, `/` is `reduce`, which means that we do the operation over each row until the end. For example, `[1,2,3,4]+/` would become `((1+2)+3)+4`, which is the sum of the array `[1,2,3,4]`.
So, if we apply `«/` to the 2D array we just obtained, we would get:
```
([2,2,5,4]«[2,5,4,2])«[5,4,2,2]
```
which, because of the vectorization, would be equivalent to:
```
[2«2«5,2«5«4,5«4«2,4«2«2]
```
which computes the minimum of every array without the element at the index.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 3 [bytes](https://github.com/DennisMitchell/jelly)
### Now possible in 3 [bytes](https://github.com/DennisMitchell/jelly), since [2017-08-13](https://github.com/DennisMitchell/jellylanguage/commit/c41aa1416ad7d6c8543120031d11f947028f9833):
```
Ṃ-Ƥ - map minimum over overlapping outfixes of length one less than the input
```
[Try it online!](https://tio.run/##y0rNyan8///hzibdY0v@//8fbaJjrGOkYxoLAA)
---
### Original, 5 [bytes](https://github.com/DennisMitchell/jelly)
```
=Ṃ‘ịṢ
```
**[Try it online!](https://tio.run/nexus/jelly#@2/7cGfTo4YZD3d3P9y56P///9EmOsY6RjqmsQA "Jelly – TIO Nexus")**
#### How?
```
=Ṃ‘ịṢ - Main link: list a     e.g.  [4,3,2,5]
 Ṃ    - minimum of a                2
=     - equals? (vectorises)        [0,0,1,0]
  ‘   - increment                   [1,1,2,1]
    Ṣ - sort a                      [2,3,4,5]
   ị  - index into                  [2,2,3,2]
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~42~~ ~~41~~ 39 bytes
EDIT:
* -1 byte thanks to nimi!
* -2 bytes. One thanks to xnor! And one by myself.
`f` takes a list of integers (or any `Ord` type) and returns a list.
```
f(x:y)=minimum y:(fst<$>zip(f$y++[x])y)
```
[Try it online!](https://tio.run/nexus/haskell#LYqxDsIgGIR3n8KBAVIksVptie3u7NgwEIX2TwQboLH48oiNueS7L5czEmwLNign7wHN9glWeWbkhP34ejPNsFPywfktOLDDruuv@TsoJwhh6zdpvPBIWgMWzGy2kWPtwwV1H5iwRrEo@kWQSFLqj/RAS1qJTbbyb6e8VTl19jPdZza0WVn/@gs "Haskell – TIO Nexus")
`f` recurses while rotating the list. `x` is the first list element and `y` the remainder. Since the recursion is infinite, the result list needs to be cut off: `fst<$>zip...y` is a shorter way of saying `take(length y)...`.
[Answer]
# Octave, 26 bytes
```
@(x)sort(x)((x==min(x))+1)
```
A similar approach as used in [this answer](https://codegolf.stackexchange.com/a/117777/31516), which happens to be the same as [this](https://codegolf.stackexchange.com/a/117779/31516).
I'm not really a fan of just porting other answers, which is why I'd like to note that I had a similar idea before I saw the other ones. 
**Explanation:**
Jonathan Allan has already provided a good explanation for the Jelly-code, so this covers the Octave-bit, and why it works (and wouldn't work in MATLAB).
```
@(x)                       % An unnamed anonymous function taking a vector x as input
    sort(x)                % Gives a sorted version of x
            (x==min(x))    % Checks if each element is equal to the minimum value
           ((x==min(x))+1) % Adds 1 to the boolean vector, to use as indices
@(x)sort(x)((x==min(x))+1) % Complete function
```
This doesn't work in MATLAB, since inline assignments and direct indexing doesn't work. `sort(x)(1)` gives an error in MATLAB, not the first element in the sorted vector.
[Answer]
## Haskell, 41 bytes
```
a#(b:c)=minimum(a++c):(b:a)#c
a#b=b 
([]#)
```
Usage example: `([]#) [4,3,2,5]`-> `[2,2,3,2]`. [Try it online!](https://tio.run/nexus/haskell#@5@orJFklaxpm5uZl5lbmquRqK2drGkFFEvUVE7mSlROsk3iSrPViI5V1vyfm5iZp2CrUFCUmVeioKKQphBtomOsY6RjGvsfAA "Haskell – TIO Nexus")
Start with an empty accumulator `a` and run down the input list. The next element in the output list is the minimum of the accumulator `a` and all but the first element of the input list (->`c`) followed by a recursive call with the first element `b` added to the accumulator and `c`. Stop when you reach the end of the input list.
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), ~~13~~ 12 bytes
```
l+₁:?⊇ᶠ⁽⌋ᵐb↔
```
[Try it online!](https://tio.run/nexus/brachylog2#@5@j/aip0cr@UVf7w20LHjXufdTT/XDrhKRHbVP@/4820zHWMQVCi9j/UQA "Brachylog – TIO Nexus")
*Saved one byte thanks to @ais523.*
### Explanation
```
l+₁:?            The list [length(Input) + 1, Input]
     ⊇ᶠ⁽         Find the length(Input) + 1 first subsets of the Input
        ⌋ᵐ       Get the min of each subset 
           b↔    Remove the first element and reverse
```
We exploit the fact that `⊇` unifies subsets from biggest to smallest. For example for `[1,2,3]`, the subsets we get are in this order: `[1,2,3], [1,2], [1,3], [2,3], [1], [2], [3], []`.
We can see that the subsets `[1,2], [1,3], [2,3]` are the ones we want the minimum from, but are in the reverse order compared to the input list (hence the `↔`). We can select those subsets only by finding the first `length(Input) + 1` subsets, which will contain all of them + the entire list first. We discard that entire list with `b`.
[Answer]
## JavaScript (ES6), ~~50~~ 46 bytes
```
a=>a.map((_,i)=>Math.min(...a.filter(_=>i--)))
```
Edit: Saved 4 bytes thanks to @Arnauld.
[Answer]
# R, ~~46~~ 31 bytes
```
l=scan();sort(l)[(min(l)==l)+1]
```
implements [Stewie Griffin's solution](https://codegolf.stackexchange.com/a/117781/67312) in R, alas, my original idea is 50% longer! still reads the list from stdin, but now returns a much more readable numeric vector.
[Try it online!](https://tio.run/nexus/r#@59jW5ycmKehaV2cX1SikaMZrZGbmQekbW1zNLUNY/@bKRgrmAKhxX8A)
### old implementation:
```
l=scan();Map(function(x)min(l[-x]),match(l,l))
```
reads in the list from stdin. A negative index `l[-x]` excludes the element from the list, and `match(l,l)` returns the index of the first occurrence of each element of the list. Returns a list.
[Answer]
# [Actually](https://github.com/Mego/Seriously), 13 bytes
```
;;S╝m╗⌠╜=╛E⌡M
```
Uses the same technique that [xnor also discovered](https://codegolf.stackexchange.com/a/117779/45941).
[Try it online!](https://tio.run/nexus/actually#@29tHfxo6tzcR1OnP@pZ8GjqHNtHU2e7PupZ6Pv/f7SJjoIRGJnGAgA "Actually – TIO Nexus")
Explanation:
```
;;S╝m╗⌠╜=╛E⌡M
;;             make two extra copies of input list
  S╝           sort one and save it in register 1
    m╗         save the minimum of the other in register 0
      ⌠╜=╛E⌡M  for each value in list:
       ╜=╛E      return the minimum element of the input list if the value is not equal to the minimum, else return the second-smallest element
```
[Answer]
# [Uiua](https://www.uiua.org/), 8 bytes
```
/↧÷⊞≠.⍏.
```
Vyxal port is 10 bytes:
```
⊏⊃'=/↧'⊏⍏.
```
[Try these online!](https://www.uiua.org/pad?src=ZiDihpAg4oqP4oqDJz0v4oanJ-KKj-KNjy4KZyDihpAgL-KGp8O34oqe4omgLuKNjy4K4oqDZiBnIFs0IDMgMiA1XQriioNmIGcgWzQgMiAyIDVd)
```
/↧÷⊞≠.⍏.    input: a positive integer vector
   ⊞≠.⍏     a matrix of the size of the input where the diagonal is 0s and
              the rest are 1s
  ÷      .    divide each number in the input by each row of the above matrix,
              giving infinities where division by 0 occurs
/↧            minimum of each column
⊏⊃'=/↧'⊏⍏.
 ⊃        .   fork on two functions with two copies of input vectors as arguments:
   '=/↧        for each element, 1 if it is the minimum, 0 otherwise
       '⊏⍏    input sorted
⊏              select 0th or 1st item from the sorted list
```
Alternative 8:
```
⊏=0⊃⍏⊏⍏.
```
[Try it online!](https://www.uiua.org/pad?src=ZiDihpAg4oqPPTDiioPijY_iio_ijY8uCmcg4oaQIC_ihqfDt-KKnuKJoC7ijY8uCuKKg2YgZyBbNCAzIDIgNV0K4oqDZiBnIFs0IDIgMiA1XQ==)
```
⊏=0⊃⍏⊏⍏.
   ⊃⍏⊏⍏.    take the input array and push (rank, sorted)
     ⍏  ⍏     rank: lowest number is replaced with 0, next lowest 1, ...
       ⊏⍏.     sorted: lowest number is placed first, next 2nd, ...
 =0             for each element, 1 if rank is 0, 0 otherwise
⊏               select 1st in the sorted array if rank 0, 0th otherwise
```
[Answer]
# Python 2, 51 bytes
I know there's already a better Python solution, but I still want to post mine.
```
lambda L:[min(L[:i]+L[i+1:])for i in range(len(L))]
```
[**Try it online**](https://tio.run/nexus/python2#ZY9BDoMgEEX3nmLCCiJdgKJI0p7AG1AWNtWWRKkxNj2@HWhj0pRZDP/9GfIhhGS2hAIkKAd4DicAK1EictGS/5ZMVoUjCku7rxVlEQvNGkTa2fcE1IgbaH5xBBHr3UgYJb6bEUw3HM/b2E2XawetsZMPtLXGu7y1PhfGseGxgAcfYOnCradjjwOMue1192MPwsyLDysM1If5uVLGNlvygkuu4u@wf24VMoWlY3YuYiaeknGN/Q0)
[Answer]
## Mathematica 34 Bytes
```
Min[#~Drop~{i}]~Table~{i,Tr[1^#]}&
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 68 59 bytes
```
($a=$args)|%{$b+=@((($c=$a|sort)[0],$c[1])[$_-eq$c[0]])};$b
```
[Try it online!](https://tio.run/nexus/powershell#@6@hkmirkliUXqxZo1qtkqRt66ChoaGSDBSrKc4vKtGMNojVUUmONozVjFaJ100tBLINYmM1a61Vkv7//2/23/i/KRBafM3L101OTM5IBQA "PowerShell – TIO Nexus")
I'm pretty confident it can be shortened, I will continue to look at it
[Answer]
## C, 85 bytes
```
i,j,m;f(d,o,n)int*d,*o;{for(i=n;i--;)for(m=d[!i],j=n;j;o[i]=m=--j^i&&d[j]<m?d[j]:m);}
```
First argument is the input integer array. The second argument is the output integer array. The third argument is the element count for both arrays. 
See it [work online](https://ideone.com/oEtVbb).
[Answer]
# [Perl 6](https://perl6.org), ~~26 24~~ 19 bytes
## 26
```
{.map: (.Bag∖*).min.key}
```
Note that is `∖` U+2216 not `\` U+5C
[Try it](https://tio.run/nexus/perl6#ZY5LTsMwFEXnXsVVB9Shqaum9EfUCjFDYsisySAkBlnkYzUOoooyZwVshhlLYSPh2WorEPbonvPetZta4nUh0pAVB1ykVSax6VtRJPoaXNwmz9/vH5eeKFQpXuSh62nqxsjaYINclbLm3tenqHWuDB@Ot0Ob0qp45JMoG01suitNyBp65YG2QqbzpMTIVYTsqdof28ZbcESq1I3xEck3LVMjM3hoGaBq2I9xpz0fJ@1j0Dom7lVthJb7vLNN7WngFx@wrt9dYYYA8xh0aA67gCKhmJEK/qvAqQWNzOmu4qOycWYvySWmbue8N8WS8Brrv9gCi1dn4TBF6v0B "Perl 6 – TIO Nexus")
```
{.map: (.Bag⊖*).min.key}
```
[Try it](https://tio.run/nexus/perl6#ZY5LTsMwFEXnXsVVB9Shqaum9EfUCjFDYsisySAkBlnkYzUOooqyARbAZpixFDYSnq22AmGP7jnvXbupJV4XIg1ZccBFWmUSm74VRaKvwcVt8vz9/nHpiUKV4kUeup6mboysDTbIVSlr7n19ilrnyvDheDu0Ka2KRz6JstHEprvShKyhVx5oK2Q6T0qMXEXInqr9sW28BUekSt0YH5F80zI1MoOHlgGqhv0Yd9rzcdI@Bq1j4l7VRmi5zzvb1J4GfvEB6/rdFWYIMI9Bh@awCygSihmp4L8KnFrQyJzuKj4qG2f2klxi6nbOe1MsCa@x/ostsHh1Fg5TpN4f "Perl 6 – TIO Nexus")
## 24
```
{(.min X%$_)X||.sort[1]}
```
[Try it](https://tio.run/nexus/perl6#ZY7NSsNAFIX38xSHUu2EplOS/hNa3AouXRSSIJqMMJA/MhNR0jyZO18s3gltVZy7Ouc799xptMTbWiQByz9wm5SpxL5vuchVgePN@Mk5nk5Cl7UJvbjrKXNnpDbYI1OF1Nz5@hS6ypThk9lhYlVS5i98HqXTuVX3hQlYQzceaStgVfZcYDpUBOy1rM9tswM4IlVUjXERyfdKJkamcNAyQGnYb/EBiweljePiknExan@AqGSddbauvQR@@SPW9eESC/hYxaBHOYQ@SbJiRsj/j/wBrSmyotnGZ2Tlwg7BDbxh57rnYUP2Dru/tjWsvb2CwSZJvd8 "Perl 6 – TIO Nexus")
## 19
```
{.sort[.min X==$_]}
```
[Try it](https://tio.run/nexus/perl6#ZY7PSsNAGMTv@xRDEbuh6Zam/wkpXgWPHoQkiE1WWEg2IbsRJeTJvPli8dvQVsX9TjO/mWFbI/G2FVnIyg/cZlUuEQ2dMFVjY1EqjacounlO@4HwnZXGIkKhtDTc@/oUpi6U5dP5cepUVpUnvkjy2cKpe21D1tL8I7VCVhcvGrNxImSvVXNemx/BkShdt9ZHIt9rmVmZw0PHAGXgfsRHLB6UsZ6PS8bHpPsBopZN0bu57hL45U9YP8RrrBBgk4Ie5RAHJMlKGaHgPwpGtKXIhm6fnpGTK3cEd1iOnWtviR3ZBxz@2s5w9v4KRpsk7X4D "Perl 6 – TIO Nexus")
---
## 26
```
{           # bare block lambda with implicit parameter ｢$_｣
  .map:     # for each of the values in the input (implicit method call on ｢$_｣)
  (
    .Bag    # turn the block's input into a Bag
    ∖       # set-difference           ｢∖｣ U+2216 aka ｢(-)｣
    # ⊖     # symmetric-set-difference ｢⊖｣ U+2296 aka ｢(^)｣
    *       # turn expression into a WhateverCode lambda (this is the parameter)
  ).min.key # get the minimum pair from the Bag, and return its key
}
```
I used the "fancy" unicode [operators](https://docs.perl6.org/language/setbagmix) rather than the ascii equivalents because they would have required a space before them so that they wouldn't be parsed as part of the `.Bag` method call.
## 24
```
{
  (.min X% $_) # the minimum cross modulus-ed with the input
  X||          # cross or-ed 
  .sort[1]     # with the second minimum
}
```
## 19
```
{
  .sort\        # sort the values
  [             # index into that
    .min X== $_ # the minimum cross compared with the input
  ]
}
```
---
(The 24 and 19 byte golfs were inspired by a [Jelly](https://codegolf.stackexchange.com/questions/117774/moving-modest-minimum/117777#117777) implementation)
[Answer]
## Clojure, ~~36~~ ~~81~~ ~~62~~ 71 bytes
Newest (shouldn't really submit these in a hurry):
```
#(for[c[(zipmap(range)%)]i(sort(keys c))](apply min(vals(dissoc c i))))
```
[Try it online](https://tio.run/nexus/clojure#dYxBCsMgFET3nmKgFP7fpk3pXcSFGC2fGhUNgeTy1q5L3ywf8zotPiDgQiFX7TSdUlZbqNr08nxlI9Ry3ejtjwbHbMiWEg@skmi3sdEirWUHB@EvSlGpkraYQKOzj7TWd9wwYTYKPww3/XWP8ZvHnsYw9/4B).
Aaaand this one has a bug (62 bytes), zipmap produces an unordered map so this won't produce the correct sequence on larger inputs.
```
#(for[c[(zipmap(range)%)][i v]c](apply min(vals(dissoc c i))))
```
`v` is not actually used for anything but this is shorter than `i (keys c)`.
Previous at 81 bytes:
[Try it online](https://tio.run/nexus/clojure#dYxBCsMgEEX3nuJDKYzbNCm9yzALMbEMGCNahPby1q5L3l8@3u@0bgEBFwpHYc/00by7TMWl52avVljRxAu5nOMbuyZqLlZatdbDw0PtD2MoF02vmEAjb@ORecYNExYx@GO46dTdR7eMPUSs7f0L).
```
#(let[r(range(count %))](for[i r](apply min(for[j r :when(not= i j)](nth % j)))))
```
[Try it online](https://tio.run/nexus/clojure#dU1LCsIwFNznFANSeNlWKyJ4kpBF0MSmpC/hkSqePoZuxZnNMB@m0cMHBBwo@WqExPHT0z1vXDFobSlkMRFiyZWSPlgj79YCwfU9eybO9YaIpXe5zhi62qEUFYlcE4NWV179xJgTjhgxWYUf9Gz8m537buq8WKt1a18).
Oh damn the original (36 bytes) does not work when the minimum number is repeated, `[4 2 2 5]` results in `[2 4 4 2]` as both `2`s are removed :(
```
#(for[i %](apply min(remove #{i}%)))
```
`#{i}` is the set which contains only `i`, it returns truthy for `i` and falsy for others, meaning that the minimum is calculated from all other numbers within the input list.
[Try it online](https://tio.run/nexus/clojure#dYtNCoAgFAb3nuIDEZ7b/ugu4iJIQVATCSGis9vbRzPLYTrtzsNDkj@qCVCWtlLihRQyVZeO5iDv8CjNCEGlhnzGDEpbafwZM2HEgNkKfOA2/LaFv5ldrdW69xc).
[Answer]
# Pyth, ~~8~~ 7 bytes
```
mh.-SQ]
```
*-1 Byte thanks to @isaacg*
[Try it!](https://pyth.herokuapp.com/?code=mh.-SQ%5D&input=%5B9%2C+8%2C+9%5D&test_suite=1&test_suite_input=%5B4%2C3%2C2%2C5%5D%0A%5B4%2C2%2C2%2C5%5D%0A%5B6%2C3%2C5%2C5%2C8%5D%0A%5B7%2C1%5D%0A%5B9%2C9%5D%0A%5B9%2C8%2C9%5D&debug=0)
[Answer]
# [Factor](https://factorcode.org/), 38 bytes
```
[ all-rotations [ rest infimum ] map ]
```
[Try it online!](https://tio.run/##bczfCoIwFAbw@z3F1wMoqFlW0G100010JV4MmSDotO0IhfjsazP8A7UPxvbxO6fgOTXKPO7X2@UILZ6dkLnQy8sXL1Jco1WC6N2qUhJOjPUM9vTYIkKIGIP7buCdXRnauHqYUfgfhSu0syOxTeLYhFwVjZnYHsF3z3pXYOsJHGx@wFjOIFnIBJKxHtjATApeVZ5qiFPZSI0USmhCKYuy7mpkqHmLzLjbNx8 "Factor – Try It Online")
Get all the rotations of the input, then get the smallest element in each rotation minus the first element. Like this:
\$\begin{matrix}
4 & 3 & 2 & 5 \\
\end{matrix} \rightarrow\$
  
\$\require{enclose}\begin{matrix}\enclose{horizontalstrike}{4} & 3 & \color{red}{2} & 5 \\
\enclose{horizontalstrike}{3} & \color{red}{2} & 5 & 4 \\
\enclose{horizontalstrike}{2} & 5 & 4 & \color{red}{3} \\
\enclose{horizontalstrike}{5} & 4 & 3 & \color{red}{2} \\
\end{matrix} \rightarrow\$
  
\$\begin{matrix}
2 & 2 & 3 & 2 \\
\end{matrix}\$
[Answer]
# [J](https://www.jsoftware.com), 7 bytes
```
1<./\.]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m70wa8FNVUtFK8NYM0UrS3V1LiU99TQFWysFdQUdBQMFKyDW1VNwDvJxW1pakqZrsdzQRk8_Ri8WwrvZp8mVmpyRr2AEhMZArGulkKZgAmaaImSMEDJGCBljBVMgBkGwnBlYwFTBAiJrqGAOETdXMISIWAIhWATEgAhZAFkWMEEgB-KqBQsgNAA)
J's outfix adverb `\.` is made for this. It applies a verb (in this case min) to every outfix of a list of a specified size (in this case 1). Outfix being the inverse operation of "window" functions which exist in most languages -- a list composed of the original list without a window as that window moves across the list.
[Answer]
# PHP, 72 Bytes
```
<?$k=$g=$_GET;sort($k);foreach($g as&$v)$v=$k[$v==$k[0]?:0];print_r($g);
```
[Online Version](http://sandbox.onlinephpfunctions.com/code/360e9ea9c9cb808cb2c458e83bf1e1c8d67732b3)
[Answer]
# PHP, 47 bytes
```
while(++$i<$argc)echo@min([z,$i=>z]+$argv),' ';
```
[Answer]
# Scala, 37 bytes
```
l.indices map(i=>l diff Seq(l(i))min)
```
`l` is any collection of Int.
Test cases:
```
scala> val l = List(4,3,2,5)
l: List[Int] = List(4, 3, 2, 5)
scala> l.indices map(i=>l diff Seq(l(i))min)
res0: scala.collection.immutable.IndexedSeq[Int] = Vector(2, 2, 3, 2)
scala> val l = List(4,2,2,5)
l: List[Int] = List(4, 2, 2, 5)
scala> l.indices map(i=>l diff Seq(l(i))min)
res1: scala.collection.immutable.IndexedSeq[Int] = Vector(2, 2, 2, 2)
scala> val l = List(6,3,5,5,8)
l: List[Int] = List(6, 3, 5, 5, 8)
scala> l.indices map(i=>l diff Seq(l(i))min)
res2: scala.collection.immutable.IndexedSeq[Int] = Vector(3, 5, 3, 3, 3)
scala> val l = List(7,1)
l: List[Int] = List(7, 1)
scala> l.indices map(i=>l diff Seq(l(i))min)
res3: scala.collection.immutable.IndexedSeq[Int] = Vector(1, 7)
scala> val l = List(9,9)
l: List[Int] = List(9, 9)
scala> l.indices map(i=>l diff Seq(l(i))min)
res4: scala.collection.immutable.IndexedSeq[Int] = Vector(9, 9)
scala> val l = List(9,8,9)
l: List[Int] = List(9, 8, 9)
scala> l.indices map(i=>l diff Seq(l(i))min)
res5: scala.collection.immutable.IndexedSeq[Int] = Vector(8, 9, 8)
```
This can probably still be golfed, I couldn't find a shorter way to remove an element from a list than `l diff Seq(l(i))`
[Answer]
# C#, 36 Bytes
```
i.Select((x,a)=>i.Where((y,b)=>b!=a).Min())
```
Takes the elements (i) and looks in the elements without the current item for the minimal value.
It's kind of sad, that some other attempts don't work, as we work with primitive types, and therefore don't have lists with references to compare the items from.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
{sWQè
```
Port of [*@xnor*'s Python 2 answer](https://codegolf.stackexchange.com/a/117779/52210).
[Try it online](https://tio.run/##MzBNTDJM/f@/ujg88PCK//@jTXQMdYx1zGIB) or [verify all test cases](https://tio.run/##MzBNTDJM/W/u5nl4gr2SwqO2SQpK9v@ri8MDD6/4r/M/2kTHWMdIxzSWC8gygrLMgGKmQGgBZJvrGAJJSx1LMGkBpk10DIEqzGIB).
**Explanation:**
```
{        # Sort the (implicit) input-list
         #  i.e. [4,1,3,6] → [1,3,4,6]
 s       # Swap, so the (implicit) input-list is at the top of the stack again
  W      # Get the minimum without popping from the list
         #  i.e. [4,1,3,6] → 1
   Q     # Check for each element if they are equal to this value (1/0 as truthy/falsey)
         #  i.e. [4,1,3,6] and 1 → [0,1,0,0]
    è    # Use these 0s and 1s to index in the sorted list
         #  i.e. [1,3,4,6] and [0,1,0,0] → [1,3,1,1]
```
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 7 bytes
Port of xnor's Python 2 answer. Requires `⎕IO←0`:
```
∧⊇⍨⊢=⌊/
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qG@qp/@jtgkG/x91LH/U1f6od8WjrkW2j3q69P@nAcUf9fZBlHQ1H1pv/KhtIpAXHOQMJEM8PIP/pymYKBgrGCmYcoFYRlCWGVDMFAgtgGxzBUMgaalgCSYtFCwB "APL (Dyalog Extended) – Try It Online")
Explanation:
```
∧⊇⍨⊢=⌊/  ⍝ Monadic function train
      ⌊/  ⍝ The minimum element of the input
    ⊢=    ⍝ Element-wise compare the input to the above
          ⍝ Results in a boolean vector, let's call it "X"
∧         ⍝ Sort the input
 ⊇⍨      ⍝ Index into sorted input by X
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~49~~ 38 bytes
-11 bytes thanks to mazzy
```
($a=$args)|%{($c=$a|sort)[$_-eq$c[0]]}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfmvkqZgq1D9X0Ml0VYlsSi9WLNGtVpDJRnIqSnOLyrRjFaJ100tVEmONoiNrf1fy8WlpKKhBtRkomCsYKRgqqmEEDBCFTADqjAFQguEkLmCIYJjqWCJzLFA5hoaAM0yAWoGqf8PAA "PowerShell – Try It Online")
Improvement of [Sinusoid's lovely answer](https://codegolf.stackexchange.com/a/117815/78849). Saves 10 bytes by using explicit output instead of building an array. Indexes into the sorted array to either spot 0 (i.e. smallest value) or spot 1 if the conditional is true.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 6 bytes
```
mo▼`-¹
```
[Try it online!](https://tio.run/##yygtzv7/Pzf/0bQ9CbqHdv7//z/aRMdYx0jHNBYA "Husk – Try It Online")
[Answer]
# [K (ngn/k)](https://bitbucket.org/ngn/k), 12 bytes
```
{(&/x_)'!#x}
```
[Try it online!](https://tio.run/##y9bNS8/7/z/NqlpDTb8iXlNdUbmi9n@auoaJgrGCkYKptQmQBNFmQL4pEFpYmysYWlsqWAKxhYKl5n8A "K (ngn/k) – Try It Online")
Uses `list _ int` to remove individual values from the input, then takes the minimum of the remaining values.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
s∇g=İ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJz4oiHZz3EsCIsIiIsIls0LDEsMyw2XSJd)
## How?
```
s∇g=İ
s      # Sort the input
 ∇     # Push this two values down so that there are two copies of the input on top
  g    # Get the minimum of the input
   =   # For each in the input, is it equal to that?
    İ  # Index this into the sorted list
```
]