------
## 最终结论
```python
def minTaps(n, ranges):
    max_reach = [0] * (n + 1)
    for i in range(n + 1):
        left = max(0, i - ranges[i])
        right = min(n, i + ranges[i])
        max_reach[left] = max(max_reach[left], right)

    taps_opened = 0
    current_end = 0
    farthest = 0
    i = 0

    while i < n:
        while i <= current_end:
            farthest = max(farthest, max_reach[i])
            i += 1
        
        if current_end == farthest:
            return -1
        
        taps_opened += 1
        current_end = farthest

    return taps_opened
```