------
## 最终结论
```python
def countTriplets(arr):
    n = len(arr)
    
    # Step 1: Create a prefix XOR array
    prefixXor = [0] * (n + 1)
    
    for i in range(n):
        prefixXor[i + 1] = prefixXor[i] ^ arr[i]
    
    # Step 2: Count the number of valid triplets (i, j, k)
    count = 0
    
    for j in range(1, n + 1):
        xor_a = prefixXor[j]  # This is the XOR from arr[0] to arr[j-1]
        
        for k in range(j, n + 1):
            xor_b = prefixXor[k] ^ prefixXor[j - 1]  # This is the XOR from arr[j] to arr[k-1]
            
            if xor_a == xor_b:
                count += 1
                
    return count

# Example usage:
arr1 = [2,3,1,6,7]
print(countTriplets(arr1))  # Output: 4

arr2 = [1,1,1,1,1]
print(countTriplets(arr2))  # Output: 10

arr3 = [2,3]
print(countTriplets(arr3))  # Output: 0

arr4 = [1,3,5,7,9]
print(countTriplets(arr4))  # Output: 3

arr5 = [7,11,12,9,5,2,7,17,22]
print(countTriplets(arr5))  # Output: 8
```