Solution in C
Code


# Code
```c []
int* arrCreation(int* arr, int n){
    int* arr1 = (int*)malloc(n * sizeof(int));
    for(int i=0; i<n; i++)
        arr1[i] = arr[i];
    return arr1;
}
void arraySort(int* arr, int n){
    for(int i=0; i<n-1; i++){
        for(int j=0; j<n-i-1; j++){
            if(arr[j] > arr[j+1]){
                int temp = arr[j];
                arr[j] = arr[j+1];
                arr[j+1] = temp;
            }
        }
    }
}
int minimumRightShifts(int* nums, int numsSize) {
    int index = -1;
    int* arr = (arrCreation(nums, numsSize));
    arraySort(arr, numsSize);

    for(int i=0; i<numsSize; i++){
        if(nums[i] > nums[(i+1) % numsSize]){
            if(index != -1) return -1;
            index = i+1;
        }
    }
    if(index == -1) return 0;
    for(int i=0; i<numsSize; i++){
        if(nums[(i+index) % numsSize] != arr[i]) return -1;
    }
    return numsSize-index;
}
```
['C']