```python
def max_sum(tri, n):
    """
    Finds the maximum path sum from the top to the bottom of a number triangle
    by working from the bottom up.
    """
    # Iterate upwards from the second-to-last row.
    for row_index in range(n - 2, -1, -1):
        # For each element in the current row, update its value.
        for col_index in range(row_index + 1):
            # The element's new value is its current value plus the
            # maximum of the two elements directly below it.
            tri[row_index][col_index] += max(
                tri[row_index + 1][col_index],
                tri[row_index + 1][col_index + 1]
            )

    # The top element now holds the maximum path sum.
    # This handles the case of a single-row triangle as well, as the loops won't run.
    if n > 0:
        return tri[0][0]
    else:
        return 0
```