------
## 最终结论
```python
from collections import defaultdict, deque

def minJumps(arr):
    if len(arr) <= 1:
        return 0

    graph = defaultdict(list)
    
    # Create a graph where each value points to its indices
    for i in range(len(arr)):
        graph[arr[i]].append(i)

    visited = [False] * len(arr)
    queue = deque([0])  # Start from the first index
    visited[0] = True
    steps = 0

    while queue:
        for _ in range(len(queue)):
            index = queue.popleft()
            
            # Check if we reached the last index
            if index == len(arr) - 1:
                return steps
            
            # Explore neighbors: index + 1 and index - 1
            for neighbor in (index + 1, index - 1):
                if 0 <= neighbor < len(arr) and not visited[neighbor]:
                    visited[neighbor] = True
                    queue.append(neighbor)
            
            # Explore all indices with the same value
            while graph[arr[index]]:
                same_value_index = graph[arr[index]].pop()
                if not visited[same_value_index]:
                    visited[same_value_index] = True
                    queue.append(same_value_index)

        steps += 1
    
    return -1  # This line should never be reached if input constraints are respected

# Example usage:
print(minJumps([100,-23,-23,404,100,23,23,23,3,404]))  # Output: 3
print(minJumps([7]))                                  # Output: 0
print(minJumps([7,6,9,6,9,6,9,7]))                   # Output: 1
print(minJumps([6,1,9]))                             # Output: 2
print(minJumps([11,22,7,7,7,7,7,7,7,22,13]))        # Output: 3
```