------
## 最终结论
```python
import heapq

def lastStoneWeight(stones):
    # Create a max heap using negative values since heapq is a min-heap by default
    max_heap = [-stone for stone in stones]
    heapq.heapify(max_heap)
    
    while len(max_heap) > 1:
        # Take the two heaviest stones
        first = -heapq.heappop(max_heap)
        second = -heapq.heappop(max_heap)
        
        if first != second:
            # If they are not equal, push the difference back to the heap
            heapq.heappush(max_heap, -(first - second))
    
    # If there is a stone left, return its weight; otherwise return 0
    return -max_heap[0] if max_heap else 0

# Example usage:
print(lastStoneWeight([2,7,4,1,8,1]))  # Output: 1
```