def get_dim_last_value(array, dim):
    """Get the value of the last element in a dimension"""
    indices = tuple(0 if i != dim else array.shape[dim] - 1 for i in range(len(array.shape)))
    return array[indices]