scala solution
```scala []
object Solution {
  def minimumRightShifts(nums: List[Int]): Int = {
    val mn = nums.min
    val sorted = nums.sorted
    val (t,d) = nums.to(List).span(_ > mn)
    if(sorted sameElements nums) 0
    else if(sorted sameElements (d++t)) d.length
    else -1
  }
}
```
['Array', 'Scala']