def median(lst, lst_size=None):
    """Compute median."""
    lst = sorted(lst)
    if lst_size:
        n = lst_size
        n_diff = n - len(lst)
        i = (n - 1) // 2 - n_diff
        if i < 0:
            if i == -1 and not n % 2:
                return lst[0] / 2.
            return 0
    else:
        n = len(lst)
        i = (n - 1) // 2

    return lst[i] if n % 2 else (lst[i] + lst[i + 1]) / 2.