import math


def percentile(arr, percentiles):
    """Computes the percentile values in an array.

    Parameters
    ----------
    arr : list of int or float
        Input array.
    percentiles : list of int or float
        List of percentile values to compute, must be between 0 and 100 inclusive.

    Returns
    ------
    output : list
        Output array of the same length as `percentiles`.
    """
    if not arr:
        return []
    arr = list(sorted(arr))
    output = [0] * len(percentiles)
    for idx, p in enumerate(percentiles):
        x = (len(arr) - 1) * (p / 100)
        f = math.floor(x)
        c = math.ceil(x)
        if f == c:
            output[idx] = arr[int(x)]
        else:
            output[idx] = (c - x) * arr[int(f)] + (x - f) * arr[int(c)]
    return output