------
## 最终结论
```python
def max_coins(piles):
    # Sort the piles in descending order
    sorted_piles = sorted(piles, reverse=True)
    
    # Choose the elements at indices 1, 4, 7,... (3k + 2)
    return sum(sorted_piles[i] for i in range(1, len(sorted_piles), 3))

# Example usage
piles = [2, 4, 1, 2, 7, 8]
result = max_coins(piles)
print(result)  # Output: 9
```