------
## 最终结论
```python
def maxDistance(position, m):
    position.sort()
    
    def canPlaceBalls(min_dist):
        count = 1
        last_position = position[0]
        
        for i in range(1, len(position)):
            if position[i] - last_position >= min_dist:
                count += 1
                last_position = position[i]
                if count == m:
                    return True
        return False

    left, right = 1, position[-1] - position[0]
    result = 0
    
    while left <= right:
        mid = (left + right) // 2
        if canPlaceBalls(mid):
            result = mid
            left = mid + 1
        else:
            right = mid - 1
            
    return result

# Example usage:
print(maxDistance([1,2,3,4,7], 3)) # Output: 3
print(maxDistance([5,4,3,2,1,1000000000], 2)) # Output: 999999999
```