------
## 最终结论
```python
def numTeams(rating):
    team_count = 0
    for i in range(len(rating)):
        for j in range(i + 1, len(rating)):
            for k in range(j + 1, len(rating)):
                if rating[i] < rating[j] < rating[k] or rating[i] > rating[j] > rating[k]:
                    team_count += 1
    return team_count

# Example usage:
rating1 = [2, 5, 3, 4, 1]
rating2 = [2, 1, 3]
rating3 = [1, 2, 3, 4]

print(numTeams(rating1)) # Output: 3
print(numTeams(rating2)) # Output: 0
print(numTeams(rating3)) # Output: 4
```