def percentile(data, n):
    size = len(data)
    idx = (n / 100.0) * size - 0.5
    if idx < 0 or idx > size:
        raise StatisticsError("Too few data points ({}) for {}th percentile".format(size, n))
    return data[int(idx)]