def power_series(z, cs):
    """
    returns cs[0] + cs[1] * z + cs[2] * z ** 2 + ... + cs[-1] * z ** (len(cs) - 1)
    """
    s = cs[-1]
    for c in reversed(cs[:-1]):
        s *= z
        s += c
    return s