Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given a 0-indexed array nums consisiting of positive integers. You can do the following operation on the array any number of times:

Select an index i such that 0 <= i < n - 1 and replace either of nums[i] or nums[i+1] with their gcd value.

Return the minimum number of operations to make all elements of nums equal to 1. If it is impossible, return -1.
The gcd of two integers is the greatest common divisor of the two integers.
 
Please complete the following python code precisely:
```python
class Solution:
    def minOperations(self, nums: List[int]) -> int:
```