python
Code

# Code
```python3 []
class Solution:
    def minimumRightShifts(self, nums: List[int], ans = 0) -> int:
        n = len(nums)
        A = sorted(nums)
        while ans < n and nums > A:
            ans += 1
            nums = [nums.pop()] + nums 
        return ans if ans < n else -1
```
['Python3']